Laravel Composer sees wrong PHP Version(Laravel Composer 看到错误的 PHP 版本)
问题描述
I'm trying to install an older Laravel Project.
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.
When I run
php -v
I get the following result
PHP 7.1.10 (cli) (built: Oct 12 2017 14:00:12) ( ZTS )
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
}
}
How is it possible that this project thinks I have php 5.6 running?
Thank you.
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.
Example
...
"platform": {
"php": "7.1"
}
...
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 版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Laravel Composer 看到错误的 PHP 版本
基础教程推荐
- Libpuzzle 索引数百万张图片? 2022-01-01
- 通过 PHP SoapClient 请求发送原始 XML 2021-01-01
- XAMPP 服务器不加载 CSS 文件 2022-01-01
- 如何在 PHP 中的请求之间持久化对象 2022-01-01
- mysqli_insert_id 是否有可能在高流量应用程序中返回 2021-01-01
- 在多维数组中查找最大值 2021-01-01
- 在 Woocommerce 中根据运输方式和付款方式添加费用 2021-01-01
- WooCommerce 中选定产品类别的自定义产品价格后缀 2021-01-01
- 在 PHP 中强制下载文件 - 在 Joomla 框架内 2022-01-01
- 超薄框架REST服务两次获得输出 2022-01-01