Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How the CI framework installs dependency packages using composer

Shulou Source: shulou.com Published: 2022-06-02 16:56:35 11月16日 Update

This article is about how the CI framework installs dependent packages using composer. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

In this article, for the Linux system, the first step of windows is to install according to the official website of composer. The following steps are the same.

Step 1 global installation of composer

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

Step 2 create composer.json to your project root directory

{"require": {"kriswallsmith/buzz": "*"}}

Here you will add a Buzz package to handle the HTTP Request / Response PHP 5.3.x class.

Step 3 executes the following command to download the dependency package

$composer install

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

Step 4 adds automatic loading of packages to the project

Add the following line in your index.php

Require_once'. / vendor/autoload.php'

Needs to be loaded in the

Require_once BASEPATH.'core/CodeIgniter.php'

Front

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;}} Thank you for reading! This is the end of the article on "how to install dependency packages using composer in the CI framework". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it out for more people to see!

Tags: Framework content more article project good practical same one line code example global command article root directory step directory see knowledge system Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi OPPO Reno vpn Huawei Shulou Information