溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

Composer中怎么設置忽略版本匹配

發布時間:2021-07-23 14:27:03 來源:億速云 閱讀:233 作者:Leah 欄目:開發技術

Composer中怎么設置忽略版本匹配,很多新手對此不是很清楚,為了幫助大家解決這個難題,下面小編將為大家詳細講解,有這方面需求的人可以來學習下,希望你能有所收獲。

Composer簡介

Composer 是 PHP 的一個依賴管理工具。它允許你申明項目所依賴的代碼庫,它會在你的項目中為你安裝他們。Composer 不是一個包管理器。是的,它涉及 "packages" 和 "libraries",但它在每個項目的基礎上進行管理,在你項目的某個目錄中(例如 vendor)進行安裝。默認情況下它不會在全局安裝任何東西。因此,這僅僅是一個依賴管理。

執行composer install遇到錯誤:Your requirements could not be resolved to an installable set of packages. 這是因為不匹配composer.json要求的版本。

完整錯誤如下:

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下應該也是可以運行的,composer可以設置忽略版本匹配,命令是:

composer install --ignore-platform-reqs

or

composer update --ignore-platform-reqs

再次執行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

這是在虛擬機中執行composer,提示這個目錄沒有可寫權限,composer無法緩存下載的包,這樣就每次都得重新下載,把目錄改成可寫可讀即可。

sudo chmod -R 777 /home/vagrant/.composer/cache/files/

另外,在虛擬機中也設置composer為國內鏡像,不然下載速度慢的要死,執行:

composer config -g repo.packagist composer https://packagist.phpcomposer.com

看完上述內容是否對您有幫助呢?如果還想對相關知識有進一步的了解或閱讀更多相關文章,請關注億速云行業資訊頻道,感謝您對億速云的支持。

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女