Home  >  Article  >  Development Tools  >  About the steps for dependency packages installed by CI framework using composer

About the steps for dependency packages installed by CI framework using composer

藏色散人
藏色散人forward
2020-10-26 14:18:231956browse

The following tutorial column of composer will introduce to you the steps for installing dependency packages using composer for the CI framework. I hope it will be helpful to friends in need!

About the steps for dependency packages installed by CI framework using composer

The example in this article describes the relevant steps and methods of the dependency package installed by the CI framework using composer.

Share it with everyone for your reference, the details are as follows:

This article is for Linux systems, windows. The first step is to install according to the composer official website. The subsequent steps are the same

step 1 Install composer globally

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

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

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

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

step 3 Execute the following command to download the dependency package

$ composer install

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

step 4 Add automatic loading of the package in the project

Add the following line to your index.php

require_once './vendor/autoload.php';

needs to be loaded in front of

require_once BASEPATH.'core/CodeIgniter.php';

step 5 Test

The example is as follows:

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;
}
}

View more More available packages can be viewed on Packagist

The above is the detailed content of About the steps for dependency packages installed by CI framework using composer. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:jb51.net. If there is any infringement, please contact admin@php.cn delete