Laravel Composer看到错误的PHP版本 [英] Laravel Composer sees wrong PHP Version
问题描述
我正在尝试安装较旧的Laravel项目.
I'm trying to install an older Laravel Project.
当我运行composer install时,出现以下错误
When I run composer install I get the following error
This package requires php >=5.6.4 but your PHP version (5.5.35) does not satisfy that requirement.
我跑步时
php -v
我得到以下结果
PHP 7.1.10 (cli) (built: Oct 12 2017 14:00:12) ( ZTS )
这是我的composer.json的内容
This is the content of my composer.json
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": ">=5.6.4",
"doctrine/dbal": "^2.6",
"guzzlehttp/guzzle": "^6.3",
"intervention/image": "^2.4",
"intervention/imagecache": "^2.3",
"laravel/framework": "5.4.*",
"laravel/tinker": "~1.0",
"laravelcollective/html": "^5.4",
"maatwebsite/excel": "^2.1",
"sentry/sentry-laravel": "^0.8.0",
"spatie/laravel-glide": "^3.2",
"spatie/laravel-permission": "^2.6",
"spatie/laravel-pjax": "^1.3"
},
"require-dev": {
"fzaninotto/faker": "~1.4",
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "~5.7"
},
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\\": "app/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"scripts": {
"post-root-package-install": [
"php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"php artisan key:generate"
],
"post-install-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postInstall",
"php artisan optimize"
],
"post-update-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postUpdate",
"php artisan optimize"
]
},
"config": {
"preferred-install": "dist",
"sort-packages": true,
"optimize-autoloader": true
}
}
该项目怎么可能认为我正在运行php 5.6?
How is it possible that this project thinks I have php 5.6 running?
谢谢.
推荐答案
我也遇到了这个问题.如果您不想更新所有的作曲家软件包,则可以通过手动更改composer.lock
文件并在JSON对象的platform > php
中编写实际的PHP版本来解决此问题.
I've had this problem too. If you don't want to update all your composer packages, you can solve this issue by manually changing the composer.lock
file and writing your actual PHP version in platform > php
in the JSON object.
示例
...
"platform": {
"php": "7.1"
}
...
尽管有效,但最推荐的方法是删除composer.lock
文件,在composer.json
中更改platform > php
版本,然后执行composer install
.
Although it works, the most recommended way to do this would be deleting your composer.lock
file, changing the platform > php
version in composer.json
and then executing composer install
.
这篇关于Laravel Composer看到错误的PHP版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!