What is PHP Composer and How To Use It
PHP Composer is the first tool for PHP Dependency Management but not a new concept in web development it’s inspired from other languages like node.js.
What is Dependency Management?
Well, there are thousands of libraries available in PHP to use for our projects already, so there no need to write codes from scratch and waste our time. For example, you have made contact form before in your previous project, and now in your current project, you need to use same contact form again. Are going to code it again from scratch? I don’t think so, I think you are going to fetch codes from your previous project, but it might be a little difficult to fetch just contact form codes or codes you required to fetch from the whole page. So for this kind of situations, we have lots of frameworks available nowadays, but they all have their own requirements of libraries and dependencies, and because of it some issues may occur if those dependencies conflict with each other. So for this kind of solutions, we get one dependency management tool which installs libraries per project.
Top 3 Frameworks Which Requires Composer to Install Easily and Faster :
- ZendFramework 2
- Symfony 2
- Laravel 4
How to Use Composer?
Composer is a command line utility, so you have to install composer first in your system, you can download it from here. Once you install it try to find composer.json file in your framework folder, it’s just a simple json file you can open it on a browser or notepad++ to check what’s written in it to understand how it works.
Now open your command prompt or terminal, I prefer git bash but you can use whichever you like.
Check if Composer is installed correctly or not:
Write command to change your current directory to your composer file directory:
And just wait and composer will install all dependencies by itself.