composer的安装和使用
由于工作中需要用到leancloud的LeanCloud PHP SDK,支持composer安装,所以就下载composer工具了,
安装之前可以用composer命令检测是否已经安装了,命令是:composer直接回车,如果显示command not found: composer表示还未安装;如果显示了composer的图标表示已经安装了。
Suppose:
You have a project that depends on a number of libraries.
Some of those libraries depend on other libraries.
Composer:
Enables you to declare the libraries you depend on.
Finds out which versions of which packages can and need to be installed, and installs them (meaning it downloads them into your project).
安装步骤:
1.php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
2.php -r "if (hash_file('SHA384', 'composer-setup.php') === 'e115a8dc7871f15d853148a7fbac7da27d6c0030b848d9b3dc09e2a0388afed865e6a3d6b3c0fad45c48e2b5fc1196ae') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
3.php composer-setup.php
4.php -r "unlink('composer-setup.php');"
5.把composer.phar移动到环境变量里,同时把composer.phar重命名为composer,用命令 mv composer.phar /usr/local/bin/composer
使用方法:
1.在你的项目目录使用composer,切换到你的项目目录,命令 cd /Applications/MAMP/htdocs/DPOpenAPI/
2.下载你需要的文件,命令 composer require leancloud/leancloud-sdk