npm install gulp-composernpm i gulp-composer --save-dev
- PHP (obviously)
> PHP 5.3.2 or above (at least 5.3.4 recommended to avoid potential bugs)
>
> https://github.com/composer/composer#requirements
gulp-composer is that having composer [installed on the system][install-composer] is not required! However, it is still recommended as it will increase performance of the task.gulp-composer will search for composer in {working-dir}/composer.phar. If it's not found, it will attempt to use the globally installed composer command.composer(.phar) is still not found on the system, it will attempt to download it to the system temp directory. Future builds will check the system temp directory so it doesn't download it too often.``js`
composer = require('gulp-composer');
composer([ command, ] [ options ]);
| Parameter | Default | Description |
|:------------------------------- |:------------- |:------------------------------------------------------------------------------------- |
| command
String | install | The composer command to execute. See composer --help for list of available commands |gulp-composer
| options
Object | see [options] | All options for and native composer |
#### Options
| Option | Default | Description | Passed to composer |
|:------------------------------------- |:------- |:--------------------------------------------------------------------------------------------------- |:------------------ |
| bin
String | auto | Path to the composer binary. E.g. composer, /usr/bin/composer.phar, or php /path/to/composer. | No |false
| self-install
Boolean | true | Set to to disable self-install. | No |composer
| async
Boolean | true | By default, the bin will load asynchronously. Use false to run it synchronously. | No |composer
| ansi
Boolean | true | The default for this parameter is automatically passed to enable logging in color. | Yes |
| working-dir
String | [cwd] | The path with which to run composer against (normally where the composer.json is located). | Yes |
| ... | mixed | Any other arguments will be passed through to composer | Yes |
js
var composer = require("gulp-composer");gulp.task("composer", function () {
composer();
});
`Most basic setup with self-install disabled:
`js
var composer = require("gulp-composer");gulp.task("composer", function () {
composer({ "self-install": false });
});
`Adding a few options:
`js
var composer = require("gulp-composer");gulp.task("composer", function () {
composer({
"working-dir": "./php-stuff",
bin: "composer"
});
});
`
A more complex setup:
`js
var composer = require("gulp-composer"),
gutils = require("gulp-utilities");// ...
composer("init", { "no-interaction": true });
composer('require "codeception/codeception:*"', {});
if (gutils.env.production) {
composer({
"bin": "/build/share/composer.phar",
"no-ansi": true,
"self-install": false,
});
} else {
//default install
composer();
}
composer("dumpautoload", {optimize: true});
``+ Tom Westcott
+ Nathan J. Brauer
+ Joseph Richardson
[install-composer]: https://getcomposer.org/doc/00-intro.md
[cwd]: https://nodejs.org/api/process.html#process_process_cwd
[options]: #options