使用composer遇到的问题及解决方法
可以尝试利用composer下载Yii框架,编辑composer.json文件:
{ "require":{ "yiisoft/yii2":"~2.0.0" } }
然后在这个包含composer.json文件的目录下执行命令:
composer install
然后就等待下载完成
问题零: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.
需要安装一个composer资源插件,运行命令安装即可:
composer global require "fxp/composer-asset-plugin:^1.4.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中删除即可。
问题二:需要输入token
如果是第一次使用composer,那么在下载文件yii框架的过程中,有几项需要输入token,如下图:
[root@localhost tmp]# composer install Loading composer repositories with package information Updating dependencies (including require-dev) Could not fetch https://api.github.com/repos/jquery/jquery-dist, 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.localdomain+2018-02-22+1945 to retrieve a token. It will be stored in "/root/.composer/auth.json" for future use by Composer. Token (hidden):
只要粘贴上面的URL到浏览器中打开,然后生成一个token,然后复制这个新的token,在命令行中需要token的地方输入该token即可,该token会存储在用户家目录/.composer/auth.json中:
{ "bitbucket-oauth": {}, "github-oauth": { "github.com": "6ad4ef7375b1fb9........"}, "gitlab-oauth": {}, "gitlab-token": {}, "http-basic": {} }
此后可以不用再输入token了,composer会自动去auth.json中找。
如需转载,请注明文章出处,谢谢!!!