Composer Scripts
Composer scripts run shell commands or PHP callbacks as build automation steps — similar to npm scripts.
Composer scripts run shell commands or PHP callbacks as build automation steps — similar to npm scripts.
"scripts": {
"test": "phpunit --colors=always",
"lint": "php-cs-fixer fix",
"analyse": "phpstan analyse src --level=8",
"build": ["@lint", "@analyse", "@test"],
"post-install-cmd": ["php artisan optimize"],
"post-update-cmd": ["php artisan optimize:clear"]
}
// Run with: composer test or composer run build
Chain scripts with arrays — composer build runs lint, analyse, then test in sequence.