Introduction to the steps and methods of dependency packages installed by CI framework using composer

藏色散人
Release: 2019-12-12 15:08:01
forward
2431 people have browsed it

The following tutorial column ofcomposer useswill introduce to you the steps and methods of dependency packages installed by CI framework using composer. I hope it will be helpful to friends in need!

Introduction to the steps and methods of dependency packages installed by CI framework using composer

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

step 1 Global installationcomposer

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

step 2 Create composer.json to your project root directory

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

Here will 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
Copy after login

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

step 4 in Add automatic loading of packages in the project

Add the following line in your index.php

require_once './vendor/autoload.php';
Copy after login

needs to be loaded in front of

require_once BASEPATH.'core/CodeIgniter.php';
Copy after login

step 5 Test

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; } }
Copy after login

To view more available packages, you can view Packagist (https://packagist.org/explore/)

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

Related labels:
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
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!