For modern languages, Package Manager is basically standard. Java has maven,python have Pip,ruby have Gem,nodejs have NPM. PHP is pear, but pear pits a lot:
Dependency processing prone to problems
Very complex configuration
Hard-to-use command-line interface
Fortunately, we have composer,php rely on the management of the weapon. It's open source, it's easy to use, and it's easy to submit your own package.
Installing composer
Composer requires PHP 5.3.2+ to run.
$ CURL-SS Https://getcomposer.org/installer | Php
This command will download the Composer.phar to the current directory. PHAR (PHP compression package) is a compressed format that can be run directly under the command line.
You can use the--install-dir option to install composer to the specified directory, for example:
$ CURL-SS Https://getcomposer.org/installer | PHP----install-dir=bin
Of course, you can also do a global installation:
$ CURL-SS Https://getcomposer.org/installer | php$ MV Composer.phar/usr/local/bin/composer
You can also use the homebrew installation under Mac OS x:
Brew Tap Josegonzalez/homebrew-phpbrew Install Josegonzalez/php/composer
However, it is usually only possible to add the location of the Composer.phar to path, not necessarily the global installation.
Claim dependent
Create a Composer.json file under the project directory that indicates dependencies, for example, your project relies on Monolog:
{" require": { "Monolog/monolog": "1.2.*"}}
Installation dependencies
Installation dependencies are simple, just run in the project directory:
Composer Install
If there is no global installation, then run:
PHP Composer.phar Install
Auto Load
Composer provides an auto-load feature that simply includes the following line in the initialization section of your code:
Require ' vendor/autoload.php ';
Module Warehouse
Packagist.org is a warehouse of composer, where many well-known PHP libraries can be found. You can also submit your own work.
Advanced Features
The above describes the basic usage of composer. Composer also has some advanced features that, although not required, can often be handy for PHP development.
Project Home
For more information, please visit Composer's homepage.
Domestic mirror
http://pkg.phpcomposer.com/