我是tp5.1下号坡,用composer安裝擴(kuò)展包,在命令行運(yùn)行抗果,無(wú)任何不反應(yīng)筋帖,不下載也不報(bào)錯(cuò),這時(shí)冤馏,我們先ctrl+c退出執(zhí)行的命令日麸,然后在tp5.1根目錄下,找到composer.json文件逮光,并用編輯器打開(kāi)代箭,在最后追加上如下內(nèi)容:
"repositories": {
"packagist": {
"type": "composer",
"url": "https://packagist.phpcomposer.com"
}
}
保存退出,然后在cmd命令行執(zhí)行運(yùn)行命令涕刚,就ok了嗡综。
composer安裝擴(kuò)展包時(shí),可以設(shè)置忽略版本匹配杜漠,命令如下:
composer install --ignore-platform-reqs
如果不知道擴(kuò)展包的具體版本极景,可以寫(xiě) * ,* 會(huì)下載最新的版本
"require": {
"topthink/think-helper":"*"
},
或者寫(xiě) dev-master驾茴,dev-master作者也是很懵逼
"require": {
"topthink/think-helper":"dev-master"
},
再或者隨便填寫(xiě)一個(gè)不存在的版本盼樟,cmd命令執(zhí)行的時(shí)候,會(huì)報(bào)錯(cuò)锈至,這時(shí)會(huì)提示該擴(kuò)展包有哪些版本號(hào)晨缴,如作者填寫(xiě)的是 1.0 版本,當(dāng)然這個(gè)版本執(zhí)行的時(shí)候會(huì)報(bào)錯(cuò)并列出改擴(kuò)展包都有哪些版本
"require": {
"topthink/think-helper":"1.0"
},
然后填寫(xiě)到composer.json文件里峡捡,然后在命令行進(jìn)行執(zhí)行 composer update击碗,就會(huì)進(jìn)行安裝,ok了们拙。
安裝報(bào)錯(cuò)
錯(cuò)誤如下:
Your requirements could not be resolved to an installable set of packages.
Problem 1
- overtrue/http 1.0.1 requires php >=7.0 -> your PHP version (5.6.34) does not satisfy that requirement.
- overtrue/http 1.0.0 requires php >=7.0 -> your PHP version (5.6.34) does not satisfy that requirement.
- overtrue/sendcloud 1.0.0 requires overtrue/http dev-master -> satisfiable by overtrue/http[dev-master] but these conflict with your requirements or minimum-stability.
- overtrue/sendcloud 1.0.1 requires overtrue/http ^1.0 -> satisfiable by overtrue/http[1.0.0, 1.0.1].
- Installation request for overtrue/sendcloud ^1.0 -> satisfiable by overtrue/sendcloud[1.0.0, 1.0.1].
Installation failed, reverting ./composer.json to its original content.
這是因?yàn)閜hp版本不匹配稍途,如下執(zhí)行命令,進(jìn)行忽略版本
composer install --ignore-platform-reqs
或者
composer update --ignore-platform-reqs
再次執(zhí)行composer命令可以正常安裝包了砚婆。