Here when I execute php -v
, it says it has php7
but when I try to execute composer update
the response it
Your requirements could not be resolved to an installable set of packages.
Problem 1
- This package requires php >=7.0.0 but your PHP version (5.6.33) does not satisfy that requirement.
How can I fix this?
NOTE : I'm not allowed to uninstall previous version of php
Here is the composer.json
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": ">=7.0.0",
"fideloper/proxy": "~3.3",
"intervention/image": "^2.4",
"laravel/framework": "5.5.*",
"laravel/passport": "^v1",
"laravel/tinker": "~1.0"
},
"require-dev": {
"filp/whoops": "~2.0",
"fzaninotto/faker": "~1.4",
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "~6.0"
},
"autoload": {
"classmap": [
"database/seeds",
"database/factories"
],
"psr-4": {
"App\\": "app/"
},
"files": [
"app/Helpers/misc.php"
]
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"extra": {
"laravel": {
"dont-discover": [
]
}
},
"scripts": {
"post-root-package-install": [
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"@php artisan key:generate"
],
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"@php artisan package:discover"
]
},
"config": {
"preferred-install": "dist",
"sort-packages": true,
"optimize-autoloader": true
}
}
I already tried
composer update --ignore-platform-reqs
but I still I get another error, which is again related to the above problem.
Best Answer
As stated in the question you already have both the versions of PHP on your system, As Laravel uses the cli version you need to enable 7.X and disable 5.X.
You can achieve that by below commands
For More information You can install different version of PHP using the below commands
For Apache
For Ngix
To install any PHP modules, simply specify the PHP version and use the auto-completion functionality to view all modules as follows.
Now you can install most required PHP modules as per your requirements.