composer
Composer is a package manager for PHP.
Install
Read the installation docs.
# Install
php composer.phar install
# Alternate install
# See: http://stackoverflow.com/questions/21670709/could-not-open-input-file-composer-phar-error-in-symfony2-using-wamp
curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer
Moving composer.phar
into /user/local/bin/composer
makes it available from any directory. Make sure this directory is added to your shell’s PATH
environment variable.
Update
# Requires sudo to write
sudo composer self-update
Usage
Install packages
Install the exact package versions specified in composer.lock
. This should be used immediately:
- After project setup
- After changing Git branches
composer install
Update packages
Updates all packages, their dependenices, and composer.lock
.
composer update
Update specific packages
Updates a specific package, its dependencies, and composer.lock
.
composer update {namespace}/{packageName}
Troubleshooting
Authentication
Create the file: ~/.composer/auth.json
{
"github-oauth": {
"github.com": "<personalAccessToken>"
},
"http-basic": {
"repo.magento.com": {
"username": "<username>",
"password": "<password>"
}
}
}
Missing GMP extension
Composer requires PHP + GMP extension to execute. The PHP library in your shell’s PATH
may not include that. Switch PHP versions:
- Develop: Command Line: PHP
- Try running
composer install
again.