- Download and install composer (terminal command)
- Move composer to bin, and the terminal can use composer's command directly
~$ mv composer.phar /usr/local/bin/composerComposer use
- The terminal enters the project to add the tripartite Library
- 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 <[email protected]>, n to skip]: Zhao Hong Ya <[email protected]> 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": "[email protected]" } ] } Do you confirm generation [yes]?
You can also create the composer.json file manually and write data directly in it
composer search leancloud/leancloud-sdk2> Query sdk version
composer show -all leancloud/leancloud-sdk3> The composer.json file is generated 4> Run the composer install command to download the sdk, and the loading is completed
namespace LeanCloud; require "vendor/autoload.php"; use LeanCloud\Client;