How to use dependent packages installed by composer in the CI framework
This article will explain in detail how to use the composer installation dependency package in the CI framework. Xiaobian thinks it is quite practical, so share it with you as a reference. I hope you can gain something after reading this article.
This article is aimed at Linux system, windows first step according to the composer official website to install the following 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 in your project root directory
{ "require": { "kriswallsmith/buzz": "*" }}
Here we'll add a Buzz package to handle HTTP Request / Response PHP 5.3.x classes.
Step 3: Execute the following command to download the dependency package
$ composer install
Then you'll notice that the composer created a./ The vendors are in your app directory and the code is in there.
Step 4 Add package auto-loading to your project
Add the following line to your index.php
require_once './ vendor/autoload.php';
Need to load in
require_once BASEPATH. 'core/CodeIgniter.php';
front
Step 5 Testing
Examples are 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; }} About "How to use the composer installation dependency package in CI framework" This article is shared here, I hope the above content can be of some help to everyone, so that you can learn more knowledge, if you think the article is good, please share it for more people to see.