If you're a PHP
developer and has been coding up for years, you may have noticed that while developing in PHP, you have to re-invent the wheel every single time. You have to re-write several modules over and over again. You have to include and require your files every single time. Composer is basically the solution to all of these problems.
What's Composer?
Composer is a dependency manager for PHP. Composer will handle all the dependencies required in your application by pulling in all the required libraries and extensions and manage them in one place.
Composer
is for PHP
as NPM
is for JavaScript
. Composer was inspired by NPM
from NodeJS
and Bundler
From Ruby
.
Using Composer
You can use composer in your PHP project by simply init
composer in your project.
$ composer init
This command will get you through the basic configurations for your application, such as
- Package Name
- Description
- Author
- Minimum Stability
- Package Type
- License
This will generate a composer.json
file for you. You can then run:
$ composer install
to generate composer.lock
and vendor
directory.
Well, that's it. you are all set to go.