今天在本地配置了了YII 框架,花费了一段时间,再次记录一下
在天朝真的是给搞技术的带来了很多的困难
根据yiichina.com 的文档开始配置,我使用的方法是composer,http://www.yiichina.com/doc/guide/2.0/start-installation
这种方法首先要安装依赖工具:composer,
curl -s http://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer
这两句命令是没有为题的。
composer global require "fxp/composer-asset-plugin:1.0.0"
composer create-project --prefer-dist yiisoft/yii2-app-basic basic
在执行安装composer插件的时候报错了
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Changed current directory to /Users/mengmeng/.composer
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- The requested package fxp/composer-asset-plugn could not be found in any version, there may be a typo in the package name.
Potential causes:
- A typo in the package name
- The package is not available in a stable-enough version according to your minimum-stability setting
see <https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion> for more details.
Read <http://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.
Installation failed, reverting ./composer.json to its original content.
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
如果不执行这一句也是可以执行下一句的命令的,但是会报错,jquery文件不能下载之类的,
然后搜到了原因:Yii2.0要求Composer必须安装 composer asset 插件。 这个插件使得Composer可以兼容实现NPM和BOWER包管理器的功能。 NPM 和 BOWER 主要用于前端资源(如JS库等)的管理。
这个是参考:http://www.digpage.com/install.html
所以用composer方法来安装的话这个插件是一定要安装的,但是天朝封杀的太厉害了,总是会因超时之类的报错
我搜到了一个解决的方案:依靠国内的镜像站来下载依赖包文件
安装的composer会在家目录里有配置:~/.composer
安装的时候是没有config.json文件的,所以我创建了~/.composer/config.json文件
在~/.composer/config.json文件里把国内镜像站的路径写到文件里 :参考:http://pkg.phpcomposer.com/
{
"config":{
},
"repositories":[
{"type":"composer","url":"http://pkg.phpcomposer.com/repo/packagist/"},
{"packagist":false}
]
}
然后就可以成功的添加插件到composer中。
在执行最后一步的时候可能会要github.com的账号和密码:只是因为好多文件都是放在github上托管的,一部分API限制了匿名用户。
可能要20分钟装bootstrap和jquery之类的。可以通过运行http://localhost/basic/web/index.php来验证安装成功!