初次接触用composer安装php框架会遇到很多不明白的概念和流程,安装的过程也是一种学习的过程,不过有很多时候出错不一定是设置或命令错误,仅仅因为网络或者..墙的关系,不过这些不确定因素和陌生的模式,足以让部分初学者望而却步,另外包括很多解决问题的方法都是英文,在此也可以看出英语对程序员提升也很关键.
当然,yii框架并没有严格要求使用composer安装,所以也可以到官网下载相关程序包,解压使用(可能要有一些本地配置).
yii网址 : http://www.yiiframework.com/download/
composer网址 : http://www.phpcomposer.com/
因为windows安装方式偏人性化(下一步..),一般也遇不到太大问题,如果遇到(请重启...)可以百度相关问题,也可以参考另一篇博文:http://blog.csdn.net/h330531987/article/details/76184087
windows安装包下载:https://getcomposer.org/Composer-Setup.exe
下面说linux下遇到的问题:sudo mv composer.phar /usr/local/bin/composer
然后配置环境变量(如果出现'command not found ',则考虑环境变量)
vi /etc/profile
export PATH="$PATH:/usr/local/bin"
#保存后别忘执行source /etc/profile
groupadd game
useradd -g game user0
passwd user0 --设置密码
在用user0运行时可能需要用到sudo命令,此时需要root用户授权,授权配置在
vi /etc/sudoers
找到 'root ALL=(ALL) ALL ' 在下面添加一行
user0 ALL=(ALL) ALL
chmod 777 /usr/local/bin/composer
#安装composer管理前端资源(bootstrap, jquery)的插件
composer global require "fxp/composer-asset-plugin"
#再创建yii项目
composer create-project --prefer-dist yiisoft/yii2-app-basic basic
#上面为基础版,下面为高级版
composer create-project --prefer-dist yiisoft/yii2-app-advanced advanced
sudo rm -rf /home/user1/.composer/vendor/fxp
重新执行
composer global require "fxp/composer-asset-plugin"
composer self-update
zlib.output_compression = On
zlib.output_compression_level = 5
composer config repo.packagist composer https://packagist.phpcomposer.com
如果还是不行就修改全局配置(官方推荐)
composer config -g repo.packagist composer https://packagist.phpcomposer.com
"config": {
"secure-http": false
}
composer self-update
composer update
Could not fetch https://api.github.com/repos/RobinHerbots/jquery.inputmask/contents/bower.json?ref=03e65a2d28159e885e18acee9cae53ac6318372b, please create a GitHub OAuth token to go over the API rate limit
Head to https://github.com/settings/tokens/new?scopes=repo&description=Composer+on+localhost+2017-08-03+1904
to retrieve a token. It will be stored in "/home/vagrant/.composer/auth.json" for future use by Composer.
Token (hidden):
使用github账号登录
Installing laravel/laravel (v5.2.31)
Failed to download laravel/laravel from dist: The zip extension and unzip command are both missing, skipping.
The php.ini used by your command-line PHP is: /usr/local/php/lib/php.ini
Now trying to download from source
- Installing laravel/laravel (v5.2.31): Cloning 76b8ef7204
yum install -y zip unzip
顺便把curl也装了
yum install curl
如果是用
ubuntu系统,可以使用apt-get
apt-get install curl
apt-get install zip unzip