Magento 2.4.4 PHP8.1 语法测试
本文介绍两种方式:
- 本地手动运行测试
- push到Github时利用Github Actions 自动测试
1. 本地手动测试(本地需安装php 8.1 运行环境)
#切换到项目根目录运行以下命令 ! find . -not \( -path ./.phpstorm.meta.php -prune \) -type f -name "*.php" -exec php -d error_reporting=32767 -l {} \; 2>&1 1> /dev/null | grep "^"
效果如图:
2. Github Actions 自动测试
- 在项目根目录新建
.github/workflows/
文件夹 - 在
.github/workflows/
下新建php-syntax-check.yml
并添加以下代码name: "PHP Syntax Check" on: push: pull_request: jobs: php_syntax_check: name: PHP Syntax ${{ matrix.php-versions }} Check runs-on: ${{ matrix.operating-system }} needs: php_syntax strategy: max-parallel: 1 fail-fast: false matrix: operating-system: [ubuntu-latest] php-versions: ["8.1"] steps: - uses: actions/checkout@v1 - name: Setup PHP uses: shivammathur/setup-php@master with: php-version: ${{ matrix.php-versions }} extension-csv: mbstring #optional, setup extensions ini-values-csv: post_max_size=256M, short_open_tag=On #optional, setup php.ini configuration coverage: none #optional, setup coverage driver pecl: true #optional, setup PECL - name: Check PHP Version run: php -v - name: Check .php files continue-on-error: true run: '! find . -not \( -path ./.phpstorm.meta.php -prune \) -type f -name "*.php" -exec php -d error_reporting=32767 -l {} \; 2>&1 1> /dev/null | grep "^"'
来源:https://github.com/OpenMage/magento-lts