Home >Development Tools >composer >what is composer

what is composer

爱喝马黛茶的安东尼
爱喝马黛茶的安东尼Original
2019-08-15 10:02:512617browse

what is composer

Composer is a dependency management tool for PHP. We can declare the external tool libraries we depend on in the project, and Composer will help you install these dependent library files. With it, we can easily use one command to reference other people's excellent code into our project. .

Composer is not installed globally by default, but is installed based on a directory of a specified project (such as vendor).

Composer requires PHP 5.3.2 or above, and openssl needs to be turned on.

Composer can run on Windows, Linux and OSX platforms.

Related recommendations: "Composer Usage Tutorial"

Dependency Management

Composer is not a package manager. Yes, it involves "packages" and "libraries", but it's managed on a per-project basis, with installations in some directory within your project (e.g. vendor). By default it won't install anything globally. So this is just a dependency management.

This idea is not new, Composer is strongly inspired by node's npm and ruby's bundler. At that time, there was no similar tool for PHP.

Composer will solve the problem for you like this:

a) You have a project that depends on several libraries.

b) Some of these libraries depend on other libraries.

c) You declare what you depend on.

d) Composer will figure out which versions of packages need to be installed, and install them (download them into your project).

Declaring Dependencies

Let’s say you are creating a project and you need a library for logging. You decide to use monolog. In order to add it to your project, all you need to do is create a composer.json file that describes the project's dependencies.

{
    "require": {
        "monolog/monolog": "1.2.*"
    }
}

We just need to point out that our project requires some monolog/monolog package, any version starting from 1.2.

System Requirements

PHP 5.3.2 or above is required to run Composer. Some sensitive PHP settings and compilation flags are also required, but the installer will throw a warning for any incompatibilities.

We will install directly from the source of the package, rather than simply downloading the zip file, you will need git , svn or hg , depending on the version management system you are loading the package into.

Composer is multi-platform and we strive to make it run equally well on Windows, Linux and OSX platforms.

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

Statement:
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

Related articles

See more