Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Composer equivalent of npm's scripts.start

npm lets you have something like this:

{
  "scripts": {
    "start": "babel-node app.js",
  }
}

Then when you type npm start it'll start your app, with whatever command-line options you want. This provides a uniform entry point for all node apps.

Is there anything like that for Composer?

like image 507
mpen Avatar asked Dec 25 '22 15:12

mpen


1 Answers

You can add a custom "scripts" block just like in npm, but you don't need to preface the command with run when running the commands. e.g.

{
    "name": "vendor/project",
    ...
    "scripts": {
        "test": "phpunit"
    }
}

With this, you can now run composer test.

N.B. if you create a script with the same name as a "native" command, you will see this warning:

A script named about would override a native Composer function and has been skipped

However, you can still run the script via composer run-script <script>.

like image 145
mpen Avatar answered Dec 27 '22 21:12

mpen