Home >Development Tools >composer >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:232162browse

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<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 &#39;./vendor/autoload.php&#39;;<br/>

needs to be loaded in front of

require_once BASEPATH.&#39;core/CodeIgniter.php&#39;;<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(&#39;http://www.baidu.com&#39;);<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!

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