PHP has a slightly turbulent history of packet management. This was to change in early 2012, when Composer and his brother, Packagist, were launched.
A package management system did not exist in the PHP world until early 2000, when Stig Bakken started the PEAR project as a result of the Tel Aviv talks at the PHP Developers Meeting.
The operating principle of the PEAR was to incorporate a manager directly into the PHP language runtime and install the desired dependencies using the command line. Dependencies were packaged in archives and used in projects by using the “include” or “require” instructions.
All this leads us in 2009, a year with historical importance in the PHP world. Two relevant events took place:
1. Introduce robust and reliable support for namespace in PHP version 5.3
2. Setting up the PHP-FIG group during the PHP | Tek 2009 conference and launching the PSR-0 standard by them.
Suddenly, these changes have eliminated some of the significant disadvantages of PEAR and have opened the way to the modern PHP ecosystem that we know today.
Among other things, he began developing the Composer and Packagist projects, the first release of a functional version of them in March 2012. Nils Adermann and Jordi Boggiano developed them, the two continuing their maintenance to this day.
In PHP, in the beginning, we usually write most of the code, but when we advance in knowledge, we notice the benefits of using existing libraries, and we start using a consistent number of them – and write more secure and secure code.
But there is a problem. We need to install standard libraries every time, to include them manually in files.
Well, that means installing the libraries you want, setting up an autoload for them, that means you do not have to include them manually, they only include when you need them.
The Package Manager in PHP is Composer with the list of available packages at packagist.org
Install on Ubuntu-Linux
The first thing you need to do is update:
sudo apt-get update
Now, we need to make sure that we have curl installed, so we can write the commands to install it, and if it is already present, the installation will not run again:
sudo apt-get install curl
sudo apt-get install php5-curl
Then we need to make sure that we have OpenSSL installed. You need to check carefully what OpenSSL version you are using as older versions have been recently affected by the Heartbleed vulnerability.
sudo apt-get install OpenSSL
And of course, we need git:
sudo apt-get install git
Now we have to restart the server:
sudo service apache2 restart
Now we need to install Composer. This code will download composer.phar, and it will implement it in the entire system.
curl -sS https://getcomposer.org/installer | PHP
sudo mv composer.phar / usr / local / bin / composer
composer
The above command will show you if Composer is installed.
Composer together with Packagist, comprises a modern and robust packet manager that provides us with all the necessary facilities without sacrificing simplicity and a very easy learning curve.
This was the spark necessary for PHP to be able to adopt many modern software development practices. It is by far one of the most critical projects in the PHP ecosystem.