From scratch, enable composer for OSX environment, and install package HTTP_Request2

enable composer

bogon:work rudon$ curl -sS https://getcomposer.org/installer | php
All settings correct for using Composer
Downloading...

Composer (version 1.6.4) successfully installed to: /Users/rudon/work/composer.phar
Use it: php composer.phar

bogon:work rudon$ mv composer.phar /usr/local/bin/composer

The shortened command is:

curl -sS https://getcomposer.org/installer | php

mv composer.phar /usr/local/bin/composer

Reference from: http://docs.phpcomposer.com/00-intro.html


Download and deploy the package HTTP_Request2 for the project using composer

1. Assume the project directory is /var/www/cms/


2. Create composer.json in the project root directory with the following contents:

{
    "name": "Rudon",
    "description": "",
    "require": {
        "php": ">= 5.3.0",
        "pear/http_request2": "*"
    }
}

Please confirm that the package name "pear/http_request2" is correct, we can get it by searching the package name at https://packagist.org/ .


3. Start composer to perform automatic matching + download + deployment. The results are as follows:

Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 3 installs, 0 updates, 0 removals
  - Installing pear/pear_exception (v1.0.0): Downloading (100%)         
  - Installing pear/net_url2 (v2.2.2): Downloading (100%)         
  - Installing pear/http_request2 (v2.3.0): Downloading (100%)         
Writing lock file
Generating autoload files

4. Now the package has been installed and stored in {project root directory}/vendor/pear/http_request2 and   {project root directory}/vendor/pear/net_url2 , where net_url2 is a dependency package and is also installed.


5. Introduce all the packages of composer into the project index.php as follows:

<?php
     require 'vendor/autoload.php';
     $obj = new HTTP_Request2( ... );
     $obj->anyAction();



Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324801656&siteId=291194637