composer: Php version shows 7 but composer does not work
My composer.json
:
cat composer.json
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": ">=7.0.0",
"barryvdh/laravel-debugbar": "^3.1",
"fideloper/proxy": "~3.3",
"laravel/framework": "5.5.*",
"laravel/tinker": "~1.0"
},
"require-dev": {
"filp/whoops": "~2.0",
"fzaninotto/faker": "~1.4",
"mockery/mockery": "~1.0",
"phpunit/phpunit": "~6.0"
},
"autoload": {
"classmap": [
"database/seeds",
"database/factories"
],
"psr-4": {
"App\\": "app/"
}
},
"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
}
}
Output of composer diagnose
:
composer diagnose
Checking composer.json: OK
Checking platform settings: OK
Checking git settings: OK
Checking http connectivity to packagist: Warning: Accessing packagist.org over http which is an insecure protocol.
OK
Checking https connectivity to packagist: OK
Checking github.com rate limit: OK
Checking disk free space: OK
Checking pubkeys: FAIL
Missing pubkey for tags verification
Missing pubkey for dev verification
Run composer self-update --update-keys to set them up
Checking composer version: FAIL
You are not running the latest stable version, run `composer self-update` to update (1.1.2 => 1.5.6)
When I run this command:
composer install
I get the following output:
Problem 1
- This package requires php >=7.0.0 but your PHP version (5.6.32) does not satisfy that requirement.
Problem 2
- Installation request for barryvdh/laravel-debugbar ^3.1 -> satisfiable by barryvdh/laravel-debugbar[v3.1.0].
- barryvdh/laravel-debugbar v3.1.0 requires php >=7.0 -> your PHP version (5.6.32) does not satisfy that requirement.
Problem 3
- laravel/framework v5.5.9 requires php >=7.0 -> your PHP version (5.6.32) does not satisfy that requirement.
- laravel/framework v5.5.8 requires php >=7.0 -> your PHP version (5.6.32) does not satisfy that requirement.
- laravel/framework v5.5.7 requires php >=7.0 -> your PHP version (5.6.32) does not satisfy that requirement.
- laravel/framework v5.5.6 requires php >=7.0 -> your PHP version (5.6.32) does not satisfy that requirement.
- laravel/framework v5.5.5 requires php >=7.0 -> your PHP version (5.6.32) does not satisfy that requirement.
- laravel/framework v5.5.4 requires php >=7.0 -> your PHP version (5.6.32) does not satisfy that requirement.
- laravel/framework v5.5.3 requires php >=7.0 -> your PHP version (5.6.32) does not satisfy that requirement.
- laravel/framework v5.5.26 requires php >=7.0 -> your PHP version (5.6.32) does not satisfy that requirement.
- laravel/framework v5.5.25 requires php >=7.0 -> your PHP version (5.6.32) does not satisfy that requirement.
- laravel/framework v5.5.24 requires php >=7.0 -> your PHP version (5.6.32) does not satisfy that requirement.
- laravel/framework v5.5.23 requires php >=7.0 -> your PHP version (5.6.32) does not satisfy that requirement.
- laravel/framework v5.5.22 requires php >=7.0 -> your PHP version (5.6.32) does not satisfy that requirement.
- laravel/framework v5.5.21 requires php >=7.0 -> your PHP version (5.6.32) does not satisfy that requirement.
- laravel/framework v5.5.20 requires php >=7.0 -> your PHP version (5.6.32) does not satisfy that requirement.
- laravel/framework v5.5.2 requires php >=7.0 -> your PHP version (5.6.32) does not satisfy that requirement.
- laravel/framework v5.5.19 requires php >=7.0 -> your PHP version (5.6.32) does not satisfy that requirement.
- laravel/framework v5.5.18 requires php >=7.0 -> your PHP version (5.6.32) does not satisfy that requirement.
- laravel/framework v5.5.17 requires php >=7.0 -> your PHP version (5.6.32) does not satisfy that requirement.
- laravel/framework v5.5.16 requires php >=7.0 -> your PHP version (5.6.32) does not satisfy that requirement.
- laravel/framework v5.5.15 requires php >=7.0 -> your PHP version (5.6.32) does not satisfy that requirement.
- laravel/framework v5.5.14 requires php >=7.0 -> your PHP version (5.6.32) does not satisfy that requirement.
- laravel/framework v5.5.13 requires php >=7.0 -> your PHP version (5.6.32) does not satisfy that requirement.
- laravel/framework v5.5.12 requires php >=7.0 -> your PHP version (5.6.32) does not satisfy that requirement.
- laravel/framework v5.5.11 requires php >=7.0 -> your PHP version (5.6.32) does not satisfy that requirement.
- laravel/framework v5.5.10 requires php >=7.0 -> your PHP version (5.6.32) does not satisfy that requirement.
- laravel/framework v5.5.1 requires php >=7.0 -> your PHP version (5.6.32) does not satisfy that requirement.
- laravel/framework v5.5.0 requires php >=7.0 -> your PHP version (5.6.32) does not satisfy that requirement.
- Installation request for laravel/framework 5.5.* -> satisfiable by laravel/framework[v5.5.0, v5.5.1, v5.5.10, v5.5.11, v5.5.12, v5.5.13, v5.5.14, v5.5.15, v5.5.16, v5.5.17, v5.5.18, v5.5.19, v5.5.2, v5.5.20, v5.5.21, v5.5.22, v5.5.23, v5.5.24, v5.5.25, v5.5.26, v5.5.3, v5.5.4, v5.5.5, v5.5.6, v5.5.7, v5.5.8, v5.5.9].
And I expected composer to install laravel dependencies
Output of php -v
ea-php-cli Copyright 2017 cPanel, Inc.
PHP 7.0.26 (cli) (built: Dec 4 2017 16:05:39) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
Delete all kind of caches but still no success , I don’t want to update composer if possible. Thanks
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 4
- Comments: 77 (36 by maintainers)
I mean that either the information presented above has been altered for some reason (privacy or security being common ones – people assume details are not important when they, in fact, are), or your system is just broken. Like I said before, it makes no sense for Composer to detect a different php version if all of the information provided above is accurate.
Ok, well then I cannot help you any further. It makes no sense that Composer would detect a different version based on the information you provided us. So either you have not been entirely truthful, or your environment is seriously broken.
You may want to try this.
composer config platform.php YOUR_PHP_VERSION
composer config platform.php 5.6.1
https://andy-carter.com/blog/composer-php-platform
run this
composer install --ignore-platform-reqs
I hate to be repeating myself too, but it is NOT a misconfigured system. cPanel’s ea-php-cli package adds the ability to be able to have different PHP versions in different directories. It’s clearly explained here: https://confluence1.cpanel.net/plugins/servlet/mobile?contentId=2435150#content/view/2435150
And I believe we largely got to the bottom of why composer isn’t working nicely with it. I don’t see it as either composer’s fault or cPanel’s fault.
I’m happy with the workarounds for now, but very disappointed in the unnecessary cPanel bashing.
I also face the same problem:
You do realize this is an open source project with only spare time support from a number of volunteers getting paid nothing at all? Be glad there’s any support at all before complaining about the quality - if enough people with your attitude show up here it won’t be long before the free support is also going to find better things to do with their life.
That is not at all what he’s saying. As any IT professional with any minimal kind of real world experience can tell you, users lie all the time. Just most of the time not with bad intent or consciously, by forgetting errors, or configuration changes they made, or ignoring important output and then claiming there never was any, misrepresenting their local system, or etc. etc.
In his response, @alcohol was completely correctly pointing out that the issue described was technically impossible to occur given the described circumstances. So either the description was wrong (which is not necessarily lying) or the host system was fundamentally broken.
The only unprofessional thing I see here is you whining about a professional, correct and concise response from a volunteer and insulting him and his professionality.
Hate to be repeating myself, but that is only possible on a wildly misconfigured system. Hence my comment that they are different commands, you’d just logically expect the same output on a sane system, and something in cPanel is intervening.
But that’s the recurring theme here - all the workarounds I posted cannot make a difference on a sane system, and the fact that they do only prove what a mess cPanel and/or the ea-php wrappers are making of it.
I am not confident that updating the Composer version will fix anything. I really think cPanel is doing something weird. There is no reason for Composer to detect another PHP version, unless it is specifically running through another version.
Getting same output
Thanks @curry684, your first suggestion there does seem to work!
So we have 2 decent work arounds here:
composer install -d .
or
ln -s `which composer` composer
then./composer install
This doesn’t sound like a Composer issue. It sounds like you should be looking on the wamp forum.
However, if you are on Windows, run https://getcomposer.org/Composer-Setup.exe again and point it to the version of php you want to use.
Wow, great support here If i can’t do it then your problem is a lie, truly professional
I have been having same issues on my localhost. when I entered
php -v
on my command line, I saw php5.* even when my localhost and phpinfo() are showing php7.*.To solve this issue, I edited the
path
environment variable and changed the path to the php7.. Unfortunately, composer still showed me same error of php version being 5., although, I was able to getphp -v
show me version 7 instead of version 5.Finally, I reinstall composer using
composer self-update
and everything became normal.Update Default php version in WHM to use latest php version . This works for me
I confirm my idea about the fact that
.
references a path. I looked at the ea-php code, and they use the last path present in the arguments to determine the PHP version: https://github.com/CpanelInc/php-cli/blob/e2331832af3a9c61d79a666cf0a13f6513899cbb/SOURCES/src/php-cli.c#L100-L104Btw, this mean that
php process_file.php /other/project/file.json
would select the PHP version of/other/project/
too.If the directory is leading, and Composer is installed in its usual location of
/usr/local/bin/composer
, it does make sense that cPanel does not select the right executable. You could possibly work around this by symlinking, ie. run this in the project folder:Or, of course, if the PHP executable is selected correctly when not running it via env, just use:
If that shows the “right” PHP version you can also make it transparent:
And permanent:
I THINK I’VE CRACKED IT!
My last post got me thinking, I’ve discovered you can specify a custom working directory to composer, and if you just specify the currect directory it seems to correctly detect the directory’s PHP version! e.g.
composer install -d .
This ends up running composer and it correctly picks up the PHP version set by (cPanel’s MultiPHP) as 7.1, not 5.6. 😃
@purplespider There is absolutely no stubbornness on our part. We would love to see a fix for this issue, but it has nothing to do with Composer.
It is clearly a configuration issue and without knowing how you or cpanel have set things up, there is not much we can do.
Why don’t you ask the cpanel folks the best way of using a particular version of php with composer (so it can be used with
composer ...
)? Then post the solution here.Same problem when I tried to install
spatie/pdf-to-text
:Guess what, maybe someone of you uses
composer
throughgrunt
within awatch
task as a daemon process, like me.I discovered that when the command is executed as a “daemonized” grunt
watch
process, the$PATH
variable is not the same as the one I have with my user. In fact, when thewatch
task runscomposer
, the#!/usr/bin/env php
PHP interpreter resolves to version5.6.3
on my machine.Hope this helps someone!
Pretty sure it is an issue on your end, not with Composer.
You are using cPanel, that is mistake number one. Your Composer version is ancient (1.1.2), it should really be updated.
Please run the following commands in your project directory directly from the command line and give us the output (unaltered):