PHP依赖管理工具
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('SHA384', 'composer-setup.php') === '55d6ead61b29c7bdee5cccfb50076874187bd9f21f65d8991d46ec5cc90518f447387fb9f76ebae1fbbacf329e583e30') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php --install-dir="/usr/local/bin/"
php -r "unlink('composer-setup.php');"
如果安装了 Xdebug 会有下面的警告
You are running composer with xdebug enabled. This has a major impact on
runtime performance.
解决方法
~/.bash_profile
中加入
alias composer='php -n /usr/local/bin/composer.phar'
运行 source ~/.bash_profile
使用 composer
替换 composer.phar
查看版本
composer -v
查看所有命令
composer -l
不安装开发依赖
composer install --no-dev
你可以在 composer.json 的 autoload 字段中增加自己的 autoloader。
{
"autoload": {
"psr-4": {"Acme\\": "src/"}
}
}
添加 autoload 字段后,你应该再次运行 install 命令来生成 vendor/autoload.php 文件。
- You are running composer with xdebug enabled. This has a major impact on runtime performance.
composer 不调用任何 php 配置文件
~/.bashrc
中添加
# Without php.ini
alias composer='php -n /usr/local/bin/composer.phar'
source ~/.bashrc
composer -v
- Failed to decode response: zlib_decode(): data error Retrying with degraded mode, check https://getcomposer.org/doc/articles/troubleshooting.md#degraded-mode for more info
composer self-update
后重新安装