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

藏色散人
Release: 2020-10-26 14:18:57
forward
2076 people have browsed it

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/>
Copy after login

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

{<br/>  "require": {<br/>    "kriswallsmith/buzz": "*"<br/>  }<br/>}<br/>
Copy after login

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/>
Copy after login

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/>
Copy after login

needs to be loaded in front of

require_once BASEPATH.&#39;core/CodeIgniter.php&#39;;<br/>
Copy after login

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/>
Copy after login

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!

source:jb51.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!