Mastering Composer - Tips and Tricks

There is also the Scripts attribute where you can specify commands to be run before/after a command. Example from Laravel composer.json:

"scripts": {
    "post-install-cmd": [
        "php artisan clear-compiled",
        "php artisan optimize"
    ],
    "post-update-cmd": [
        "php artisan clear-compiled",
        "php artisan optimize"
    ],
    "post-create-project-cmd": [
        "php -r \"copy('.env.example', '.env');\"",
        "php artisan key:generate"
    
    ]
}