Install getcomposer

Admin   PHP   670  2020-12-30 23:27:07

getcomposer In the past, we were often annoyed with the dozens of third-party libraries that needed to be managed, so it was difficult to update the messy installs. But that is now only the past, since the Composer was born has completely changed everything. What is Composer and how is it capable? This article will guide you, help you learn about the Composer and its benefits!

1. What is Composer?

Composer - A tool to manage libraries in PHP, these tools save a lot of time with the necessary packages your project needs to use, just declare it, a composer will automatically load. The library's code comes in through a community server.

Composer helps to manage libraries specifically for each project unlike YUM (Linu X) or shared APT but similar to NodeJS npm. For example, if you have project A and project B, you need LIB X library, when installing LIB X library will be added immediately to project directory A, B.

2. Why do you need a Composer?

Composer was born to solve difficult problems such as larger project size, complex updating, inserting, and project. With Composer, you need to declare the name and version of the libraries you use without having to manually copy its code into the project, composer will automatically find and load the library you need on the Server if there is any in the library. using other libraries it will also download other libraries until all libraries are downloaded.

When using VCS, you only need to commit the version name and library name in the composer.json configuration file without having to commit changes in the code of the libraries as before. On the other hand, in your project, if there are libraries that use other libraries, as long as one of those libraries updates, composer will automatically update for you.

3. Composer installation instructions

To install Composer, your computer needs to pre-install PHP 5.3.2+ and Git preinstalled to better support the library packages. Composer supports 3 platforms OS X, Windows, and Linux well.

Composer on Linux / Unix / OSX, open Terminal and enter the command line by line

sudo php –r "readfile( '');"> composer-setup.php

sudo php composer-setup.php –install-dir=bin

sudo php –r "unlink('composer-setup.php');"

Or download composer.phar from then move it into the bin directory with the command:

sudo mv composer.phar /usr/local/bin/composer

Composer on Windows has two ways to install:

Automatic is the easiest way to install, you just need to download ComposerSetup.exe at and then install as normal software. Composer Installer will install itself into the PATH available so you can use the composer command on CMD.

Manually install:

  • You will have to download composer.phar from then move it to whatever directory you want. For example: C:\bin.
  • Create a file called composer.bat with the content:
echo @php "%~dp0composer.phar" %*>composer.bat

To use the composer command on the CMD, you need to add the Composer directory to the PATH environment variable. Finished, you can open CMD and highlight the following command to check composer –v

Install Composer

Double click the downloaded file, install it as shown below.

  • Click "Next" to proceed with the installation.
  • Note: During the installation process, if there is any error, you can ignore it by clicking "Next" to continue the installation.

Install Composer

  • Keep the default setting to choose the installation folder and continue to click "Next".

Install Composer

  • Select the area containing the PHP file and continue to Click "Next".

Install Composer

  • Proxy settings are left blank and continue to Click "Next".

Install Composer

  • Review your last choice before clicking "Install" to proceed with the installation.

  • Information sheet, click "Next".

Install Composer

  • Here is the end of the installation process, click "Finish" to finish.

Install Composer

Composer helps programmers reduce thinking about libraries and focus only on their main application. This saves our developers a lot of time doing other things. Currently, the Framework supports Composer such as: Codelgniter, Symfony2, Laravel, FuelIPHP ... Hope that through this article, programmers will have more useful tools working with PHP.