在 composer.json 中,scripts 中的一些命令未执行的排查分析
1、查看 composer.json 中的 scripts 部分。如图1
"scripts": { "post-autoload-dump": [ "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump", "@php artisan package:discover --ansi" ], "post-root-package-install": [ "@php -r \"file_exists('.env') || copy('.env.example', '.env');\"" ], "post-create-project-cmd": [ "@php artisan key:generate --ansi" ], "pre-autoload-dump": "Google\\Task\\Composer::cleanup", "lint": "phpcs --standard=PSR1,PSR2,./ruleset.xml --ignore=config/us-zipcode.php app/ routes/ config/ ", "lint-fix": "phpcbf --standard=PSR1,PSR2 --ignore=config/us-zipcode.php app/ routes/ config/ " }
2、执行命令:composer install 时,仅执行了 pre-autoload-dump、post-autoload-dump 部分下的命令。如图2
PS E:\wwwroot\object> composer install Installing dependencies from lock file (including require-dev) Verifying lock file contents can be installed on current platform. Nothing to install, update or remove Package fzaninotto/faker is abandoned, you should avoid using it. No replacement was suggested. Package swiftmailer/swiftmailer is abandoned, you should avoid using it. Use symfony/mailer instead. Package moontoast/math is abandoned, you should avoid using it. Use brick/math instead. Package phpunit/php-token-stream is abandoned, you should avoid using it. No replacement was suggested. Generating optimized autoload files > Google\Task\Composer::cleanup Class Tests\Feature\LoginApiPostCartPaymentTest located in E:/wwwroot/object/tests\Feature\ApiCartPaymentTest.php does not comply with psr-4 autoloading standard. Skipping. Class Tests\Feature\LoginApiPostCartTest located in E:/wwwroot/object/tests\Feature\ApiCartTest.php does not comply with psr-4 autoloading standard. Skipping. Class Tests\Feature\LoginGetPaymentTest located in E:/wwwroot/object/tests\Feature\PaymentTest.php does not comply with psr-4 autoloading standard. Skipping. Class Sofa\Eloquence\Searchable\Searchable located in E:/wwwroot/object/vendor/sofa/eloquence-base/src\Contracts\Searchable\Searchable.php does not comply with psr-4 autoloading standard. Skipping. Class Modules\ThemeStore\Tests\FactoryTest located in E:/wwwroot/object/Modules\ThemeStore\Tests\Unit\FactoryTest.php does not comply with psr-4 autoloading standard. Skipping. > Illuminate\Foundation\ComposerScripts::postAutoloadDump > @php artisan package:discover --ansi Discovered Package: arubacao/asset-cdn Discovered Package: axlon/laravel-postal-code-validation Discovered Package: barryvdh/laravel-debugbar Discovered Package: beyondcode/laravel-dump-server Discovered Package: beyondcode/laravel-er-diagram-generator Discovered Package: boaideas/laravel-cli-create-user Discovered Package: cviebrock/eloquent-sluggable Discovered Package: dingo/api Discovered Package: fideloper/proxy Discovered Package: genealabs/laravel-model-caching Discovered Package: igaster/laravel-theme Discovered Package: ignited/laravel-omnipay Discovered Package: intervention/image Discovered Package: jenssegers/agent Discovered Package: jgrossi/corcel Discovered Package: laravel/passport Discovered Package: laravel/scout Discovered Package: laravel/socialite Discovered Package: laravel/tinker Discovered Package: laravel/ui Discovered Package: maatwebsite/excel Discovered Package: mavinoo/laravel-batch Discovered Package: nesbot/carbon Discovered Package: newobject/facebook-conversions-api Discovered Package: nunomaduro/collision Discovered Package: nuwave/lighthouse Discovered Package: nwidart/laravel-modules Discovered Package: orangehill/iseed Discovered Package: overtrue/laravel-pinyin Discovered Package: overtrue/laravel-wechat Discovered Package: prettus/l5-repository Discovered Package: s-ichikawa/laravel-sendgrid-driver Discovered Package: sentry/sentry-laravel Discovered Package: silber/page-cache Discovered Package: socialiteproviders/manager Discovered Package: sofa/eloquence-base Discovered Package: sofa/eloquence-mutable Discovered Package: spatie/laravel-activitylog Discovered Package: spatie/laravel-permission Discovered Package: spatie/laravel-query-builder Discovered Package: spatie/laravel-sitemap Discovered Package: tamayo/laravel-scout-elastic Discovered Package: torann/geoip Package manifest generated successfully. 113 packages you are using are looking for funding. Use the `composer fund` command to find out more!
3、执行的第 1 个命令 Google\Task\Composer::cleanup 属于命令事件:pre-autoload-dump。此事件在自动加载器被转储前触发,无论是 install/update 还是 dump-autoload 命令都会触发。
4、执行的第 2、3 个命令 Illuminate\Foundation\ComposerScripts::postAutoloadDump、@php artisan package:discover –ansi 属于命令事件:post-autoload-dump。此事件在在自动加载器被转储后触发,无论是 install/update 还是 dump-autoload 命令都会触发。
5、post-root-package-install 事件在 create-project 命令期间,根包安装完成后触发。post-create-project-cmd 事件在 create-project 命令执行后触发。所以在执行命令:composer install 时未触发此 2 个事件,因此事件下所属的命令皆未执行。
6、lint、lint-fix 属于自定义的 Composer 命令。需要手动调用,例:composer lint
7、由于此项目是基于 Git 克隆至本地的,没有执行 create-project 命令。所以 create-project 命令期间触发的事件下的命令需要手动执行。如图3
PS E:\wwwroot\object> php -r "file_exists('.env') || copy('.env.example', '.env');" PS E:\wwwroot\object> php artisan key:generate --ansi Application key set successfully. PS E:\wwwroot\object>
近期评论