Composer設(shè)置忽略版本匹配的方法
Composer簡(jiǎn)介
Composer 是 PHP 的一個(gè)依賴管理工具。它允許你申明項(xiàng)目所依賴的代碼庫,它會(huì)在你的項(xiàng)目中為你安裝他們。Composer 不是一個(gè)包管理器。是的,它涉及 "packages" 和 "libraries",但它在每個(gè)項(xiàng)目的基礎(chǔ)上進(jìn)行管理,在你項(xiàng)目的某個(gè)目錄中(例如 vendor)進(jìn)行安裝。默認(rèn)情況下它不會(huì)在全局安裝任何東西。因此,這僅僅是一個(gè)依賴管理。
執(zhí)行composer install遇到錯(cuò)誤:Your requirements could not be resolved to an installable set of packages. 這是因?yàn)椴黄ヅ鋍omposer.json要求的版本。
完整錯(cuò)誤如下:
vagrant@homestead:/usr/share/nginx/html/laravel-blog$ sudo composer install Loading composer repositories with package information Installing dependencies (including require-dev) from lock file Your requirements could not be resolved to an installable set of packages. Problem 1 - Installation request for doctrine/instantiator 1.0.3 -> satisfiable by doctrine/instantiator[1.0.3]. - doctrine/instantiator 1.0.3 requires php ~5.3 -> your PHP version (7.0.3) does not satisfy that requirement. Problem 2 - doctrine/instantiator 1.0.3 requires php ~5.3 -> your PHP version (7.0.3) does not satisfy that requirement. - phpunit/phpunit-mock-objects 2.3.0 requires doctrine/instantiator ~1.0,>=1.0.1 -> satisfiable by doctrine/instantiator[1.0.3]. - Installation request for phpunit/phpunit-mock-objects 2.3.0 -> satisfiable by phpunit/phpunit-mock-objects[2.3.0].
提示我的PHP 7版本太高,不符合composer.json需要的版本,但是在PHP 7下應(yīng)該也是可以運(yùn)行的,composer可以設(shè)置忽略版本匹配,命令是:
composer install --ignore-platform-reqs
or
composer update --ignore-platform-reqs
再次執(zhí)行composer命令可以正常安裝包了。
如果提示警告:
Cannot create cache directory /home/vagrant/.composer/cache/repo/https---packagist.org/, or directory is not writable. Proceeding without cache Cannot create cache directory /home/vagrant/.composer/cache/files/, or directory is not writable. Proceeding without cache
這是在虛擬機(jī)中執(zhí)行composer,提示這個(gè)目錄沒有可寫權(quán)限,composer無法緩存下載的包,這樣就每次都得重新下載,把目錄改成可寫可讀即可。
sudo chmod -R 777 /home/vagrant/.composer/cache/files/
另外,在虛擬機(jī)中也設(shè)置composer為國內(nèi)鏡像,不然下載速度慢的要死,執(zhí)行:
composer config -g repo.packagist composer https://packagist.phpcomposer.com
OK,大功告成。
相關(guān)文章
ThinkPHP使用getlist方法實(shí)現(xiàn)數(shù)據(jù)搜索功能示例
這篇文章主要介紹了ThinkPHP使用getlist方法實(shí)現(xiàn)數(shù)據(jù)搜索功能,結(jié)合實(shí)例形式較為詳細(xì)的分析了thinkPHP基于getlist實(shí)現(xiàn)根據(jù)給定條件進(jìn)行數(shù)據(jù)的讀取、顯示等相關(guān)操作技巧,需要的朋友可以參考下2017-05-05
Laravel如何創(chuàng)建服務(wù)器提供者實(shí)例代碼
這篇文章主要給大家介紹了關(guān)于Laravel如何創(chuàng)建服務(wù)器提供者的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家學(xué)習(xí)或者使用Laravel具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來一起學(xué)習(xí)學(xué)習(xí)吧2019-04-04
Laravel Validator自定義錯(cuò)誤返回提示消息并在前端展示
這篇文章主要給大家介紹了關(guān)于Laravel Validator自定義錯(cuò)誤返回提示消息并在前端展示的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家學(xué)習(xí)或者使用Laravel具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來一起學(xué)習(xí)學(xué)習(xí)吧2019-05-05
php使用workman框架實(shí)現(xiàn)socket服務(wù)以及連接客戶端
這篇文章主要介紹了php使用workman框架實(shí)現(xiàn)socket服務(wù)以及連接客戶端,本文列舉了詳細(xì)的過程和代碼展示,能夠幫助你學(xué)習(xí),需要的朋友可以參考下2021-06-06
PHP中使用memcache存儲(chǔ)session的三種配置方法
下面簡(jiǎn)單說下PHP項(xiàng)目分布式部署中,SESSION的同步方案中的一種,使用Memcache來存儲(chǔ)SESSION。并總結(jié)了三種配置方式,需要的朋友可以參考下2014-04-04

