What is composer?
Composer is version management for php libraries.
How to install composer?
curl -sS https://getcomposer.org/installer | php mv composer.phar /usr/local/bin/composer
How to use composer?
Run this command to see help screen:
Composer works with 2 files and 1 directory:
composer.json- list of your project dependencies
composer.json, points to exact commits of the used libraries
vendor- folder with all libraries
Start working on the project
You need to install modules that are defined in project? Install them!
Adding and updating modules
You want to update module version?
composer require phpunit/phpunit 3.7.*
This command will change 2 files:
And add new files to
Development and production
- It is not recommended to run
composercommands on production system.
- It is recommended to save
composer.lockin your repository to use the same version on every environment.
- You can ignore
vendorfolder in your git repo.
You can use this ways to specify versions:
dev-master- latest commit in branch master
*- latest commit in main branch (in most cases it is master branch)
3.7.*- any version starts with 3.7
~3.7- the same as
3.7.*[RECOMMENDED FOR USE]
3.7.1- exact version
Composer is using Semantic Versioning - major.minor.patches The idea is that patches should never broke functionality and only major updates can broke backward compability.
- Find more information at composer official web-site
Feel informed? I hope so.
I will be glad to answer your questions or get some feedback from you here in comments below.