Composer
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.
System Requirements
Composer in its latest version requires PHP 8.3.14 to run. A long-term-support version (2.2.x) still offers support for PHP 5.3.2+ in case you are stuck with a legacy PHP version.
Installation
Download and run Composer-Setup.exe. It will install the latest Composer version and set up your PATH so that you can call composer from any directory in your command line.
Add php path in environment variable
Installing from composer.lock
composer install
or composer i
- The above command installs all dependencies listed in composer.lock file.
Uninstalling the specific package
composer remove <package-name>
Example:
composer remove barryvdh/laravel-debugbar
- The above command removes specific package (barryvdh/laravel-debugbar) and updates composer.json and composer.lock files.
Updating dependencies to their latest versions
composer update
- The above command updates all dependencies to latest matching versions (according to composer.json file) and updates composer.lock file.
composer update <package-name>
or composer rm <package-name>
Example:
composer update laravel/fortify
- The above command updates specific package ( laravel/fortify ) to it latest matching version and updates composer.lock file.
Upgrading packages
composer bump
- The above command increases the lower limit of your composer.json requirements to the currently installed versions. It ensures that dependencies do not accidentally get downgraded due to some other conflict, and can slightly improve dependency resolution performance as it limits the amount of package versions Composer has to look at.