注:composer.phar 与 composer是一个东西,本文安装使用composer.phar
//下载安装脚本 - composer-setup.php - 到当前目录
php -r "copy('https://install.phpcomposer.com/installer', 'composer-setup.php');"
//执行安装过程。
php composer-setup.php
//删除安装脚本
php -r "unlink('composer-setup.php');"
//在php程序根目录使用
/root/composer.phar install
//更换Packagist中国全量镜像,修改 composer 的全局配置文件
composer.phar config -g repo.packagist composer https://packagist.phpcomposer.com
或者用下面方法安装
1、使用命令下载 curl -sS https://getcomposer.org/installer | php 2、下载之后设置环境变量 mv composer.phar /usr/local/bin/composer 3、修改权限,否则执行会出错 chmod -R 777 /usr/local/bin/composer
问题0:Your requirements could not be resolved to an installable set of packages.
如果出现下面这种情况:
Loading composer repositories with package information Updating dependencies (including require-dev) Your requirements could not be resolved to an installable set of packages.
需要安装一个插件(plug),运行命令安装即可:
composer global require "fxp/composer-asset-plugin:^1.4.1"
提示我的PHP 7版本太高,不符合composer.json需要的版本,但是在PHP 7下应该也是可以运行的,composer可以设置忽略版本匹配,命令是:
composerinstall --ignore-platform-reqs
or
composerupdate --ignore-platform-reqs
问题1:proc_get_status() has been disabled for security reasons
如果出现下面这种情况:
[ErrorException] proc_get_status() has been disabled for security reasons PHP Fatal error: Uncaught exception ‘ErrorException‘ with message ‘proc_get_status() has been disabled for security reasons‘ in phar:///usr/local/bin/composer/vendor/symfony/process/Process.php:1279
这是因为安全原因,将proc_get_status函数禁用了,可以通过编辑php的配置文件php.ini,搜索proc_get_status,将他从disable_functions中删除即可。