- ¿Qué es composer? ¿Por qué utilizar composer?
What is composer? Why use composer?
Discover what composer is and its importance in web development
Léelo en Español
/ 3-5 mins. Composer is a system to manage dependencies in projects to program in PHP
, which provides us with standardized formats to manage libraries in PHP. Composer was developed by Jordi Boggiano and Nils Adermann in 2012, who are still leading the project.
Composer is installed on the server directly through the console or command line, allowing the user to install PHP applications
that are available in their dependencies. The general composer repository contains the available packages, where you can download and update the software packages on which our project is based. Today it is widely used by national and foreign companies to manage libraries, such as Transbank's Webpay Plus, which in its latest API REST version is based on Composer.
The objective of composer is to facilitate the start of a project and that you can do required tasks faster by installing libraries and maintaining them.
Why use Composer?
It is classic developers' maxim to not reinvent the wheel
and it is that, nowadays, most websites contain common libraries, such as sending emails, form validations, even in design matters such as Bootstrap; And even if you work natively, the use of APIs is today a vital issue in systems development.
So, when using a third-party library, which in turn depends on other packages or library downloads, it will be pre-installed through Composer in an automated way, leaving you the exclusive task of maintaining and updating libraries.
Basic Commands in Composer and operation
The following describes basic Composer commands.
require: add the library parameter to the composer.json file and install it.
install: install all composer.json libraries. It is the command used to download all the PHP dependencies from the repository.
update: updates the composer.json libraries according to the allowed versions indicated.
remove: uninstall a library and remove it from 'composer.json'.
The operation of composer is basically managed by a file called composer.json
that is installed in the root folder from where you are going to install the project. This file has a JSON structure which allows you to manage and view the dependencies that you are using in the project in question. When installing a package, a folder called / vendor /
will be created which will contain folders with the libraries and basic dependencies for the operation of your web project. I limit myself to not giving examples and describing the operation in a basic way
- Compártelo con tus amigos