I am trying to install Laravel 5.6 on a cPanel sandbox and I am getting strange behavior where composer is trying to use PHP 5.6 even though 7.2 is setup. Here are the details:
# composer --version
Composer version 1.1.1 2016-05-17 12:25:44
The command which php
returns nothing. But when I do alias
I get the following:
alias php='/usr/local/bin/ea-php72'
And if I run php -v I see
# php -v
PHP 7.2.4 (cli) (built: Apr 4 2018 00:56:46) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
I am going to assume that it’s working. As you can tell, I have very little experience running Laravel on cPanel, but I digress.
Here’s the error:
# composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- This package requires php ^7.1.3 but your PHP version (5.6.35) does not satisfy that requirement.
Problem 2
- laravel/framework v5.6.9 requires php ^7.1.3 -> your PHP version (5.6.35) does not satisfy that requirement.
- laravel/framework v5.6.8 requires php ^7.1.3 -> your PHP version (5.6.35) does not satisfy that requirement.
- laravel/framework v5.6.7 requires php ^7.1.3 -> your PHP version (5.6.35) does not satisfy that requirement.
- laravel/framework v5.6.6 requires php ^7.1.3 -> your PHP version (5.6.35) does not satisfy that requirement.
- laravel/framework v5.6.5 requires php ^7.1.3 -> your PHP version (5.6.35) does not satisfy that requirement.
- laravel/framework v5.6.4 requires php ^7.1.3 -> your PHP version (5.6.35) does not satisfy that requirement.
- laravel/framework v5.6.3 requires php ^7.1.3 -> your PHP version (5.6.35) does not satisfy that requirement.
- laravel/framework v5.6.2 requires php ^7.1.3 -> your PHP version (5.6.35) does not satisfy that requirement.
- laravel/framework v5.6.15 requires php ^7.1.3 -> your PHP version (5.6.35) does not satisfy that requirement.
- laravel/framework v5.6.14 requires php ^7.1.3 -> your PHP version (5.6.35) does not satisfy that requirement.
- laravel/framework v5.6.13 requires php ^7.1.3 -> your PHP version (5.6.35) does not satisfy that requirement.
- laravel/framework v5.6.12 requires php ^7.1.3 -> your PHP version (5.6.35) does not satisfy that requirement.
- laravel/framework v5.6.11 requires php ^7.1.3 -> your PHP version (5.6.35) does not satisfy that requirement.
- laravel/framework v5.6.10 requires php ^7.1.3 -> your PHP version (5.6.35) does not satisfy that requirement.
- laravel/framework v5.6.1 requires php ^7.1.3 -> your PHP version (5.6.35) does not satisfy that requirement.
- laravel/framework v5.6.0 requires php ^7.1.3 -> your PHP version (5.6.35) does not satisfy that requirement.
- laravel/framework 5.6.x-dev requires php ^7.1.3 -> your PHP version (5.6.35) does not satisfy that requirement.
- laravel/framework v5.6.15 requires php ^7.1.3 -> your PHP version (5.6.35) does not satisfy that requirement.
- Installation request for laravel/framework 5.6.* -> satisfiable by laravel/framework[5.6.x-dev, v5.6.0, v5.6.1, v5.6.10, v5.6.11, v5.6.12, v5.6.13, v5.6.14, v5.6.15, v5.6.2, v5.6.3, v5.6.4, v5.6.5, v5.6.6, v5.6.7, v5.6.8, v5.6.9].
Now, I did find a thread that says to add a platform to the composer.json:
"platform": {
"php": "7.1.3"
}
This did let me install my vendor packages, but it’s obviously not meant to be a solution since you are simply faking the platform (I think). When it comes time to really use php7 I get the following error on null coalescing operator, which is a php 7 feature, and so it’s still trying to use php5.6.
> IlluminateFoundationComposerScripts::postAutoloadDump
Parse error: syntax error, unexpected '?' in /public_html/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php on line 233
Additional notes:
phpinfo() - PHP Version 7.2.4
php.ini - /opt/cpanel/ea-php72/root/etc
core PHP Version 7.2.4
# /usr/bin/env php -v
ea-php-cli Copyright 2017 cPanel, Inc.
PHP 5.6.35 (cli) (built: Apr 4 2018 00:55:31)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
My required composer.json is as follows:
"require": {
"php": "^7.1.3",
"edujugon/laravel-google-ads": "^1.4",
"fideloper/proxy": "^4.0",
"laravel/framework": "5.6.*",
"laravel/tinker": "^1.0"
}
Any ideas on how I can fix this?
2
Answers
As it turns out the solution ended up being that we needed to change the default server wide php version to 7.2, and so we did. Since we have a shared hosting setup we set all previous existing sites to default locally to 5.6 and going forward any Laravel installation will be set to 7.2. Not sure if this is the best solution but it certainly did the trick.
what is your php version mentioned in composer.json file ? make sure it looks like this
or you can try one of these solutions
1) try reinstalling php on your server
2) you can ignore dependencies like this
composer install --ignore-platform-req
s