Vijaya Chandran Mani
@vijaycs85
Composer is a tool for dependency management in PHP. It allows you to declare the libraries your project depends on and it will manage (install/update) them for you.
Package A
Package B
Package C
Package D
Package E
1.0.0
2.0.0
1.0.0
1.2.0
4.0.0
drupal/core
guzzlehttp/guzzle
guzzlehttp/promises
^6.3
^1.0
composer show --tree
^8.8
composer
Repository
packagist.org
Repository
packages.drupal.org/8
{
"name": "myorg/mysite",
"type": "project",
"require": {
"myorg/mymodule": "^1"
}
}{
"name": "myorg/mysite",
"type": "project",
"require": {
"composer/installers": "^1.0.24",
"drupal/core": "^8.8"
},
"extra": {
"installer-paths": {
"core": ["type:drupal-core"],
"libraries/{$name}": ["type:drupal-library"],
"modules/contrib/{$name}": ["type:drupal-module"],
"profiles/contrib/{$name}": ["type:drupal-profile"],
"themes/contrib/{$name}": ["type:drupal-theme"],
"drush/Commands/contrib/{$name}": ["type:drupal-drush"],
"modules/custom/{$name}": ["type:drupal-custom-module"],
"themes/custom/{$name}": ["type:drupal-custom-theme"]
},
}
}
"require": {
"drupal/core": "8.8.2", // exactly 8.8.2
// >, <, >=, <= | specify upper / lower bounds
"drupal/core": ">=8.7.2", // anything above or equal to 8.7.2
"drupal/core": "<8.7.2", // anything below 8.7.2
// * | wildcard
"drupal/core": "8.7.*", // >=8.7.0 <8.8.0
// ~ | allows last digit specified to go up
"drupal/core": "~8.7.2", // >=8.7.2 <8.8.0
"drupal/core": "~8.7", // >=8.7.0 <9.0.0
// ^ | doesn't allow breaking changes (major version fixed - following semver)
"drupal/core": "^8.7.2", // >=8.7.2 <9.0.0
"drupal/core": "^0.3.2", // >=0.3.2 <0.4.0 // except if major version is 0
}