How composer works

爱喝马黛茶的安东尼
Release: 2019-08-12 11:19:42
Original
7869 people have browsed it

How composer works

The meaning of Composer

1. What is Composer?

Composer is a dependency management tool for PHP. Simply put, our projects usually use other code libraries. At this time, we only declare which code libraries we depend on in the project. By default, it will not be globally Install anything.

2. What is the meaning of Composer?

For modern languages, dependency management tools are basically standard. Java has Maven, Python has pip, Ruby has gem, and Nodejs has npm. PHP is PEAR, but PEAR has many pitfalls: dependency processing is prone to problems, configuration is very complex, command line interface is difficult to use, etc.

It is precisely because of the emergence of Composer that the problem of project dependency has been solved and PHP development work has become like stacking blocks.

Related recommendations: "Composer command usage graphic tutorial"

Through a simple example, let us understand how to use Composer.

1. Create a new composer.json file in the project root directory and write the following content:

How composer works

2. Execute the composer install command to install the package dependencies

How composer works

3. Directory structure

How composer works

4. Development using packages

How composer works

Working Principle of Composer

How does Composer work? For example, when we install a software, we usually install it through the app store. When we develop PHP projects, we will also face the same problem. For example, if we need a tool to record business logs, can we download the tools we need through a PHP application store?

How composer works

Packagist is Composer’s default development package repository. You can submit your installation package to packagist. In the future, if you create a new tag or update the code in your VCS (source code management software, such as Github) warehouse, packagist will automatically build a new development package. This is how packagist currently works, in the future packagist will allow you to directly upload development packages and publish your own packages.

The above is the detailed content of How composer works. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template