Composer¶
Maestro\Composer\Task\ComposerTask
Manage composer JSON and update dependencies.
Parameters¶
require Use composer to require packages (
package=>version) -array<string, string>requireDev Use composer to require dev packages (
package=>version) -array<string, string>remove Use composer to remove packages -
list<string>dev Add requirements to
require-dev-boolintersection Only update packages if are already included in the existing
composer.json(i.e. do not add packages) -boolcomposerBin Name of composer executable (will be detected automatically if omitted) -
stringupdate If composer update/install should be executed -
boolsatisfactory Do not update a dependency if it is already satisfied by the existing constraint -
boolwithAllDependencies Include dependencies when performing an update (
--with-all-dependenciesflag) -boolrunScripts Run composer scripts on update -
bool
Description¶
This task manipulates composer.json, uses the composer and provides
package information to downstream tasks.
Require and remove packages,
Perform a composer update.
Create
composer.jsonif it doesn’t exist.Creates the
Maestro\Composer\Fact\ComposerJsonFact
Require / remove packages¶
The require package is the same as it’s composer.json equivilent:
new ComposerTask(
require: [
"my-package" => "^1.0"
]
)
NOTE: If the package exists in exactly the same version the operation will be skipped (i.e. it is idempotent). Removal:
new ComposerTask(
remove: [
"my-package"
]
)
If you only wish to update existing packages (useful if you want to ensure
that a certain version of a package is shared by all your packgaes) you can
use the intersection option:
new ComposerTask(
intersection: true,
requireDev: [
"phpstan/phpstan" => "^0.12",
"phpunit/phpunit" => "^9.0",
"infection/infection" => "^18.0"
]
)
Above we update the (dev) version of these packages only if they are found in composer.json.
If you only want to update packages if they are not within the bounds of the
target constriant, use the satisfactory option:
new ComposerTask(
satisfactory: true
require: [
"symfony/console" => "^5.3"
]
)
Above, given the symfony/console is already required as ^5.0 we will not
update it as ^5.0 includes ^5.3
Update package¶
By default the task will not update composer. To update all packages:
new ComposerTask(
update: true
)
To update only specific packages:
new ComposerTask(
require: [
'package/one' => '^1.0',
],
update: true
)