Install composer packages from within gulp, even without composer itself installed on the system.
npm i gulp-composer --save-dev
-
PHP (obviously)
PHP 5.3.2 or above (at least 5.3.4 recommended to avoid potential bugs)
Part of the magic of gulp-composer
is that having composer
installed on the system is not required! However, it is still recommended as it will increase performance of the task.
- By default,
gulp-composer
will search for composer in{working-dir}/composer.phar
. If it's not found, it will attempt to use the globally installedcomposer
command. - If
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.
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 |
options Object |
see options | All options for gulp-composer and native composer |
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 |
self-install Boolean |
true | Set to false to disable self-install. |
No |
async Boolean |
true | By default, the composer bin will load asynchronously. Use false to run it synchronously. |
No |
ansi Boolean |
true | The default for this parameter is automatically passed composer 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 |
Most basic setup:
var composer = require("gulp-composer");
gulp.task("composer", function () {
composer();
});
Most basic setup with self-install disabled:
var composer = require("gulp-composer");
gulp.task("composer", function () {
composer({ "self-install": false });
});
Adding a few options:
var composer = require("gulp-composer");
gulp.task("composer", function () {
composer({
"working-dir": "./php-stuff",
bin: "composer"
});
});
A more complex setup:
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 [email protected]
- Nathan J. Brauer [email protected]
- Joseph Richardson [email protected]