Home >Development Tools >composer >About the steps for dependency packages installed by CI framework using composer
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!
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<br/>$ mv composer.phar /usr/local/bin/composer<br/>
step 2 Create composer.json to the root directory of your project
{<br/> "require": {<br/> "kriswallsmith/buzz": "*"<br/> }<br/>}<br/>
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<br/>
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';<br/>
needs to be loaded in front of
require_once BASEPATH.'core/CodeIgniter.php';<br/>
step 5 Test
The example is as follows:
class Test extends CI_Controller<br/>{<br/> public function index()<br/> {<br/> $browser = new Buzz\Browser();<br/> $response = $browser->get('http://www.baidu.com');<br/> echo $browser->getLastRequest()."\n";<br/> echo $response;<br/> }<br/>}<br/>
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!