The CI framework uses composer for dependency package installation steps and methods analysis, cicomposer

Source: Internet
Author: User
Tags composer install

The CI framework uses composer for dependency package installation steps and methods analysis, cicomposer

This document describes how to use the composer to install dependency packages in the CI framework. We will share this with you for your reference. The details are as follows:

For Linux systems, the first step for windows is to install it on the composer official website. The subsequent steps are the same.

Step 1Global installation of composer

$ curl -sS https://getcomposer.org/installer | php$ mv composer.phar /usr/local/bin/composer

Step 2Create composer. json to the root directory of your project.

{  "require": {    "kriswallsmith/buzz": "*"  }}

A Buzz package will be added to process the HTTP Request/Response PHP 5.3.x class.

Step 3Run the following command to download the dependency package:

$ composer install

Then you will notice that composer has created a./vendors in your application directory and the code is also in it.

Step 4Automatically add packages to a project

Add the following line in your index. php

require_once './vendor/autoload.php';

To load

require_once BASEPATH.'core/CodeIgniter.php';

Front

Step 5Test

Example:

class Test extends CI_Controller{  public function index()  {    $browser = new Buzz\Browser();    $response = $browser->get('http://www.baidu.com');    echo $browser->getLastRequest()."\n";    echo $response;  }}

For more available packages, see Packagist

Related Article

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.