This is an installer that will download NodeJS and NPM and install them in your Composer dependencies. Installation is skipped if NodeJS is already available on your machine.
NodeJS is increasingly becoming a part of the tool-chain of modern web developers. Tools like Bower, Grunt, Gulp... are used everyday to build applications. For the PHP developer, this means PHP projects have build dependencies on NodeJS or Bower / NPM packages. The NodeJS-installer attempts to bridge the gap between NodeJS and PHP by making NodeJS easily installable as a Composer dependency.
Building on this package, other packages like koala-framework/composer-extra-assets can be used to automatically fetch Bower / NPM packages, run Gulp / Grunt tasks, etc...
Simply include this package in your composer.json
requirements:
{
"require": {
"mouf/nodejs-installer": "~1.0"
}
}
By default, if NodeJS is not available on your computer, it will be downloaded and installed in vendor/nodejs/nodejs.
You should access NodeJS and NPM using the scripts created into the vendor/bin directory:
A number of options are available to customize NodeJS installation:
{
"require": {
"mouf/nodejs-installer": "~1.0"
},
"extra": {
"mouf": {
"nodejs": {
"version": "~0.12",
"targetDir": "vendor/nodejs/nodejs",
"forceLocal": false
}
}
}
}
Available options:
The installer listens to the following composer scripts to be launched:
{
"post-install-cmd": {
// ...
},
"post-update-cmd": {
// ...
}
}
If you need to launch the installer manually, you can run the following command:
$ composer run-script download-nodejs