How to run scripts in composer

26, January 2022

To run scripts using composer update the scripts section in composer.json

//..
"scripts": {
    "test-stan": "phpstan",
    "test-unit": "phpunit --colors=always tests",
    "test-lint": "phpcs --standard=coding_standard.xml common.php tests public config",
    "clean": "phpcbf --standard=coding_standard.xml common.php tests public config",
    "test": [
        "@test-lint",
        "@test-stan",
        "@test-unit"
    ]
},
//..

Now run composer test-stan to run phpstan. Multiple scripts can be ran by using an array

"test": [
    "@test-lint",
    "@test-stan",
    "@test-unit"
]
Peter Fisher Contract Web Developer

Peter Fisher is a UK based PHP contractor with 20 years experience in web development He can be hired to work with PHP using Symfony or Laravel or Flask and Django with Python.