composer是一个很好用的工具,类似于iOS开发项目中所用的cocopods,所以就想着安装下,过程也很简单:
1、切换到如下目录(在很多博客中都是这样写的,先安装,然后mv到/usr/local/bin目录下,其实可以直接安装),这样就可以全局使用
cd /usr/local/bin
2、安装,输入如下命令:
curl -sS https://getcomposer.org/installer | php
这个时候会报错,如下:
bogon:bin xianniuyang$ curl -sS https://getcomposer.org/installer | php All settings correct for using Composer The installation directory "/usr/local/bin" is not writable
其实就是没有读写权限,输入如下命令,输入开机密码即可开放权限:
sudo chmod a+x /usr/local/bin
3、然后再次输入安装命令 curl -sS https://getcomposer.org/installer | php 即可安装,安装成功如下:
bogon:bin xianniuyang$ curl -sS -k https://getcomposer.org/installer | php All settings correct for using Composer Downloading... Composer (version 1.9.0) successfully installed to: /usr/local/bin/composer.phar Use it: php composer.phar
4、输入如下命令:
mv composer.phar /usr/local/bin/composer
5、在自己的PHP项目中创建composer.json文件,可以建在文件夹里面;
6、执行如下命令:
composer install
7、安装成功提示如下:
bogon:MFFC xianniuyang$ composer install Loading composer repositories with package information Updating dependencies (including require-dev) Package operations: 1 install, 0 updates, 0 removals - Installing monolog/monolog (1.0.2): Downloading (100%) Writing lock file Generating autoload files
项目中如下图:
参考了几篇博客,都不怎么完整,所以按照大神博客里面的步骤自己总结了下,仅做记录!