PHP using composer

Source: Internet
Author: User

Before written related to the composer, then met a few friends asked me, I tidied up a bit, convenient for everyone to check in the future ~ ~ Do not play open source programmer is not a good cook

    1. Perform online installation         CURL-SS Https://getcomposer.org/installer | php        Execution results are as follows:           > > #!/usr/bin/env php all settings C Orrect for using Composer downloading ... > >composer successfully installed to:/root/composer.phar >  >use it:             PHP composer.phar  2. To check if composer is working properly, just use    to perform phar:php composer.phar  3.       MV Composer.phar/usr/local/bin/composer composer-v  4. Install dependencies (enter the desired project) create a Composer.json file, write the appropriate package name and version number, as { "Require":  {"Monolog/monolog": "1.0.*"  }} execute composer install, Into the automatic installation, after the installation is completed will generate a Composer.lock file, which is a specific version number name, need this file and Composer.json submitted to the version management together   (if you want to update dependent execution composer update     If you want to update only part composer update mongolog/monolog) 5. Configure the Mirror package in the country set mirror address (Chinese mirror address-G parameter indicates global configuration) composer Config-g Repo . packagist composer HTtps://packagist.phpcomposer.com set Process Execution time-out (in seconds) composer Config-g process-timeout 600 view configuration list com     Poser config-g-l  6. Automatic loading mechanism require ' vendor/autoload.php ' should be introduced in the program;    7. Then use it in PHP like this: $log = new Monolog\logger (' name ');     $log->pushhandler (New Monolog\handler\streamhandler (' App.log ', monolog\logger::warning)); $log->addwarning (' Foo ');  8. The above references a monolog/monolog package, but if you want to add additional packages such as Add Dubbo Development extension Package composer require quickj/ Dubbo-php-client can be so easy, move your hands, together high~~~

PHP uses composer

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.