logo

Give your Composer script a second name

When the name you type and the name you say don't match

Aaron Saray
Aaron Saray
2026-06-02

A composer script is often named after the underlying tool, like phpstan, because that is the binary the script calls. But what if you or the team always refers to the tool as larastan because that is the plugin or package providing most of the functionality for your project? "Did Larastan catch that?" asks another programmer, even though composer.json says phpstan.

You could rename the script, but that might break things down the line like CI. Or maybe you just want it to be named phpstan out of convention.

So, let's use Composer's scripts-aliases key.

"scripts": {
    "phpstan": [
        "@php vendor/bin/phpstan analyse"
    ]
},
"scripts-aliases": {
    "phpstan": [
        "larastan"
    ]
}

Now composer phpstan and composer larastan both invoke the same script.

When an existing script name does not match the name you naturally type, an alias is the simplest fix.

Oh, and bonus: the alias value is an array, so you can even add common typos, if you're into that sort of thing.

Here to help,

Aaron

P.S. Got a favorite Composer trick you like to use? Trade it with us. Join our community.

Toss a coin in the jar if you found this helpful.
Want a tip like this in your inbox every weekday? Sign up below 👇🏼
email
No spam. Only real-world advice.