CodoIginter framework introduces composer package manager

1. In the Linux environment, you can directly install the composer dependency manager first

  • sudo apt-get install composer

2. Because there is already a composer.json file in the framework, there is no need to create it manually.

  • composer require dependency name

You can install the dependencies you need

3. Then a vendor directory will be generated in the framework, which will place the dependencies you installed, and import the dependencies in the index.php entry file (may be different in different framework directories, depending on the situation)

 require_once "vendor/autoload.php";

4. Commonly used dependency recommendation

(1) Guzzle, it is a PHP HTTP client, used to send requests easily and integrated into our WEB service

  • composer require guzzlehttp/guzzle
    and then use it where http requests are required

 $client = new GuzzleHttp\Client();
 .....

For specific use, please refer to the document: http://guzzle-cn.readthedocs.io/zh_CN/latest/

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325522884&siteId=291194637