这篇文章上次修改于 1987 天前,可能其部分内容已经发生变化,如有疑问可询问作者。
Composer 是 PHP 的一个依赖管理工具。我们可以在项目中声明所依赖的外部工具库,Composer 会帮你安装这些依赖的库文件,有了它,我们就可以很轻松的使用一个命令将其他人的优秀代码引用到我们的项目中来。
Composer 的安装
全局安装
你可以将此文件放在任何地方。如果你把它放在系统的 PATH 目录中,你就能在全局访问它。 在类Unix系统中,你甚至可以在使用时不加 php 前缀。
你可以执行这些命令让 composer 在你的系统中进行全局调用:
移动 composer.phar,这样 composer 就可以进行全局调用:
curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer
切换为国内镜像:
composer config -g repo.packagist composer https://packagist.phpcomposer.com
更新
composer: composer selfupdate
如果你进行了全局安装,并且没有 phar 文件在当前目录,请使用下面的命令代替:
composer install
application build.php CHANGELOG.md composer.json extend index.html LICENSE.txt public README.md runtime think vendor
[root@AY1310080849526341abZ mhlife-api]# curl -sS https://getcomposer.org/installer | php -- --install-dir=bin
The defined install dir (bin) does not exist.
[root@AY1310080849526341abZ mhlife-api]# curl -sS https://getcomposer.org/installer | php
All settings correct for using Composer
Downloading...
Composer (version 1.8.6) successfully installed to: /mnt/www/mhlife/blog/mhlife-api/composer.phar
Use it: php composer.phar
[root@AY1310080849526341abZ mhlife-api]# mv composer.phar /usr/local/bin/composer
[root@AY1310080849526341abZ mhlife-api]# ls
application CHANGELOG.md extend LICENSE.txt README.md think
build.php composer.json index.html public runtime vendor
[root@AY1310080849526341abZ mhlife-api]# composer config -g repo.packagist composer https://packagist.phpcomposer.com
[root@AY1310080849526341abZ mhlife-api]# composer selfupdate
You are already using composer version 1.8.6 (stable channel).
[root@AY1310080849526341abZ mhlife-api]# composer install
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 2 installs, 0 updates, 0 removals
- Installing topthink/think-installer (v1.0.12): Downloading (100%)
The Process class relies on proc_open, which is not available on your PHP installation.
The archive may contain identical file names with different capitalization (which fails on case insensitive filesystems)
Unzip with unzip command failed, falling back to ZipArchive class
- Installing topthink/framework (v5.0.24): Downloading (100%)
The Process class relies on proc_open, which is not available on your PHP installation.
The archive may contain identical file names with different capitalization (which fails on case insensitive filesystems)
Unzip with unzip command failed, falling back to ZipArchive class
Writing lock file
Generating autoload files
[root@AY1310080849526341abZ mhlife-api]# ls
application CHANGELOG.md composer.lock index.html public runtime thinkphp
build.php composer.json extend LICENSE.txt README.md think vendor
[root@AY1310080849526341abZ mhlife-api]#
没有评论
博主关闭了评论...