Composer is an application-level batch manager for the PHP programming language that allows you to manage dependencies in a PHP application. Composer was developed and continues to be maintained by two programmers, Nils Adermann and Jordi Boggiano. They started developing Composer in April 2011, and the first release took place on March 1, 2012. The idea of creating application-level package managers is not new and its authors were inspired by the already existing npm for Node.js.
Composer works through a command line interface and installs dependencies for the application. It also allows users to install PHP applications that are available from packagist.org, which is its main repository where all available packages are contained.
Installing in the local scope
What does it mean? This means that composer is installed in a specific project folder. And you can only use it in this directory. To install in this area, you need to run the installer in the project folder. For example: we are going to install in a folder, let’s say – /home/user/www/testsite. Where, user is the Ubuntu username. In my case, the user is tonny. We go into this directory using the terminal.
cd / home / user / www / testsite
Now let’s install the composer itself directly.
curl -sS https : //getcomposer.org/installer | php
In the future, we may have problems with the rights to the directory testsite. To obtain the rights, use the command from under the parent folder. In our case www.
Now, to use composer, we use the command, again from under our directory testsite:
php composer. phar
When starting Composer, you should see the following picture, which shows the available commands and their use cases for reference purposes.
Alternatively, you can install Composer to a specific directory using –install-dir and rename it using –filename:
curl -sS https : //getcomposer.org/installer | php – –install-dir = bin –filename = composer
Where bin is the directory path, composer is the renamed composer.phar name.
Read also: Transparency in CSS
The installer will check the PHP options and then load composer.phar into the working directory. The Composer file is binary. It is a PHAR (PHP Archive) which is an archive format for PHP that can be run from the command line.
Setting in the global scope
To install in this area, install in a directory /usr/local/bin named – composer (you can call it whatever you like), use the command:
curl -sS https : //getcomposer.org/installer | sudo -H php – –install-dir = / usr / local / bin –filename = composer
In this installation, Composer can be used from under the home directory: