没有不值得去解决的问题,也没有不值得去学习的技术!

Troubleshooting Unexecuted Commands in the scripts Section of composer.json

When running the command: composer install, only the commands under the pre-autoload-dump and post-autoload-dump sections were executed

1. Check the scripts section in composer.json. See Figure 1.

Check the scripts section in composer.json.
Figure 1
Plaintext

    "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. When running the command: composer install, only the commands under the pre-autoload-dump and post-autoload-dump sections were executed. See Figure 2.

When running the command: composer install, only the commands under the pre-autoload-dump and post-autoload-dump sections were executed
Figure 2
Plaintext

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. The first command executed, Google\Task\Composer::cleanup, belongs to the command event: pre-autoload-dump. This event is triggered before the autoloader is dumped, and it fires for both the install/update and dump-autoload commands.

4. The second and third commands executed, Illuminate\Foundation\ComposerScripts::postAutoloadDump and @php artisan package:discover –ansi, belong to the command event: post-autoload-dump. This event is triggered after the autoloader is dumped, and it fires for both the install/update and dump-autoload commands.

5. The post-root-package-install event is triggered during the create-project command, after the root package is installed. The post-create-project-cmd event is triggered after the create-project command is executed. Therefore, these two events were not triggered when running the command: composer install, meaning none of the commands under these events were executed.

6. lint and lint-fix are custom Composer commands. They need to be invoked manually, for example: composer lint

7. Because this project was cloned to the local machine via Git, the create-project command was not executed. Therefore, the commands under the events triggered during the create-project command must be executed manually. See Figure 3.

Because this project was cloned to the local machine via Git, the create-project command was not executed. Therefore, the commands under the events triggered during the create-project command must be executed manually.
Figure 3
Plaintext

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>

关于作者 · 持续学习与技术实践

我是一名拥有 15 年以上开发经验的技术从业者,自 2013 年起持续运营个人技术博客,记录工作与个人项目中遇到的真实问题,以及解决问题过程中的探索、实践和思考。

除了技术写作,我也在持续开发和维护自己的独立项目,探索新技术和新工具在实际场景中的应用。我始终相信,没有不值得去解决的问题,也没有不值得去学习的技术。

如果这篇文章对你有所帮助,欢迎浏览博客中的其他文章,也欢迎交流技术经验与想法。

关于我  ·  GitHub  ·  邮件联系