《PHP教程:Composer設置忽略版本匹配的方法》要點:
本文介紹了PHP教程:Composer設置忽略版本匹配的方法,希望對您有用。如果有疑問,可以聯系我們。
PHP應用Composer簡介
PHP應用Composer 是 PHP 的一個依賴管理工具.它允許你申明項目所依賴的代碼庫,它會在你的項目中為你安裝他們.Composer 不是一個擔保理器.是的,它涉及 "packages" 和 "libraries",但它在每個項目的基礎上進行管理,在你項目的某個目錄中(例如 vendor)進行安裝.默認情況下它不會在全局安裝任何東西.因此,這僅僅是一個依賴管理.
PHP應用執行composer install遇到差錯:Your requirements could not be resolved to an installable set of packages. 這是因為不匹配composer.json要求的版本.
PHP應用完整差錯如下:
PHP應用
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應用提示我的PHP 7版本太高,不符合composer.json必要的版本,但是在PHP 7下應該也是可以運行的,composer可以設置忽略版本匹配,命令是:
PHP應用
composer install --ignore-platform-reqs
PHP應用or
PHP應用
composer update --ignore-platform-reqs
PHP應用再次執行composer命令可以正常安裝包了.
PHP應用如果提示警告:
PHP應用
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
PHP應用這是在虛擬機中執行composer,提示這個目錄沒有可寫權限,composer無法緩存下載的包,這樣就每次都得重新下載,把目錄改成可寫可讀即可.
PHP應用
sudo chmod -R 777 /home/vagrant/.composer/cache/files/
PHP應用另外,在虛擬機中也設置composer為國內鏡像,否則下載速度慢的要死,執行:
PHP應用
composer config -g repo.packagist composer https://packagist.phpcomposer.com
PHP應用OK,年夜功告成.
《PHP教程:Composer設置忽略版本匹配的方法》是否對您有啟發,歡迎查看更多與《PHP教程:Composer設置忽略版本匹配的方法》相關教程,學精學透。維易PHP學院為您提供精彩教程。
轉載請注明本頁網址:
http://www.snjht.com/jiaocheng/6835.html