最近使用composer進行php依賴管理,但是國內鏡像http://packagist.phpcomposer.com不能進行訪問,國外鏡像訪問速度很慢,請問大神還有什麼其他的國內鏡像或好的解決方案嗎?
回複內容:
最近使用composer進行php依賴管理,但是國內鏡像http://packagist.phpcomposer.com不能進行訪問,國外鏡像訪問速度很慢,請問大神還有什麼其他的國內鏡像或好的解決方案嗎?
那是因為composer預設用Https協議請求,國內鏡像之前是http的,貌似現在換了
your configuration does not allow to connection to `http://xxxxxxx`,see the https://getcomposer.org/doc/06-config.md#secure-http for details.
開啟https://getcomposer.org/doc/06-config.md#secure-http
看看
secure-http#Defaults to true. If set to true only HTTPS URLs are allowed to be downloaded via Composer. If you really absolutely need HTTP access to something then you can disable it, but using Let's Encrypt to get a free SSL certificate is generally a better alternative.
預設是必須使用https的,而你使用的鏡像是http的。
也就是在,config.json中配置
{ "config": { "secure-http": false }}
另外,如果有爬牆資源的話,可以參考下這個:
https://segmentfault.com/a/1190000000518008
我覺得吧!
還是用國外鏡像好:
1、Composer從GitHub拉取代碼檔案,Github掛了你也用不了
2、還不如做個翻/牆。
之前在用的國內鏡像:
Packagist
好像官網有說明 phpcomposer
或者將.composer/config.json修改成
{ "config": [], "repositories": { "packagist": { "type": "composer", "url": "https://packagist.phpcomposer.com" } }}
http://pkg.phpcomposer.com/ 這個應該好用啊 我前天還用了。。
http://pkg.phpcomposer.com/ 可以切換至中國鏡像。
現在好用了,謝謝大家的協助