PHP tripartite management tool composer

Composer installation

  1. Download and install composer (terminal command)
~$ curl -sS | php
~$ php -r "readfile('');" | php
  1. Move composer to bin, and the terminal can use composer's command directly
~$ mv composer.phar /usr/local/bin/composer

Composer use

  1. The terminal enters the project to add the tripartite Library

  2. Use the command composer init to configure the composer.json file
macbookdeMacBook-Pro:test macbook$ composer init
  Welcome to the Composer config generator  
This command will guide you through creating your composer.json config.

Package name (<vendor>/<name>) [macbook/test]: test
 The package name test is invalid, it should be lowercase and have a vendor name, a forward slash, and a package name, matching: [a-z0-9_.-]+/[a-z0-9_.-]+ 
Package name (<vendor>/<name>) [macbook/test]: test/test
Description []: This is a composer Testing
Author [Zhao Hong Ya <>, n to skip]: Zhao Hong Ya <>
Minimum Stability []: 
Package Type (e.g. library, project, metapackage, composer-plugin) []: 
License []: 

Define your dependencies.

Would you like to define your dependencies (require) interactively [yes]? yes
Search for a package: leancloud/leancloud-sdk
Enter the version constraint to require (or leave blank to use the latest version): v0.5.6
Search for a package: 
Would you like to define your dev dependencies (require-dev) interactively [yes]? 
Search for a package: 

    "name": "test/test",
    "description": "This is composer Testing",
    "require": {
        "leancloud/leancloud-sdk": "v0.5.6"
    "authors": [
            "name": "Zhao Hong Ya",
            "email": ""

Do you confirm generation [yes]?

You can also create the composer.json file manually and write data directly in it

Find tripartite library method

1> Terminal fuzzy query sdk
composer search leancloud/leancloud-sdk

2> Query sdk version
composer show -all leancloud/leancloud-sdk

3> The composer.json file is generated

4> Run the composer install command to download the sdk, and the loading is completed

5> The lead-in head can be used
namespace LeanCloud;
require "vendor/autoload.php";
use LeanCloud\Client; 

Tags: SDK JSON PHP curl

Posted on Fri, 31 Jan 2020 16:03:50 -0500 by jonah