Reputation: 20319
I am trying to run composer install
with the Symfony process component like this:
if ($process->isSuccessful()) {
$process = new Process("cd {$directory} && composer install");
$process->run(function ($type, $buffer) {
if (Process::ERR === $type) {
Log::info($buffer);
} else {
Log::info($buffer);
}
});
}
It points to a PHP version of 5.6.25 which looks really strange because I am 100% certain I am using PHP 7. Running a phpinfo() inside Laravel gives me:
PHP Version 7.0.13
Running php -v
from my terminal gives me:
PHP 7.0.13 (cli) (built: Nov 15 2016 23:52:36) ( NTS ) Copyright (c) 1997-2016 The PHP Group Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
This is the output that I am tailing from my log file which the Symfony process component is writing to:
Problem 1
- Installation request for phpunit/php-code-coverage 5.0.0 -> satisfiable by phpunit/php-code-coverage[5.0.0].
- phpunit/php-code-coverage 5.0.0 requires php ^7.0 -> your PHP version (5.6.25) does not satisfy that requirement.
Problem 2
- Installation request for phpunit/phpunit 6.0.6 -> satisfiable by phpunit/phpunit[6.0.6].
- phpunit/phpunit 6.0.6 requires php ^7.0 -> your PHP version (5.6.25) does not satisfy that requirement.
Problem 3
- Installation request for phpunit/phpunit-mock-objects 4.0.0 -> satisfiable by phpunit/phpunit-mock-objects[4.0.0].
- phpunit/phpunit-mock-objects 4.0.0 requires php ^7.0 -> your PHP version (5.6.25) does not satisfy that requirement.
Does anybody know why it points to a PHP version I am not using? I am running this on macOS by the way.
The strangest thing is that even if I use php -v
in the Symfony process it shows that right version so it seems composer links to a wrong PHP version? I was able to install it locally though with composer by simply requiring it through my own terminal.
If anybody needs more information I am more than willing to try some things. Let me know.
Upvotes: 3
Views: 765
Reputation: 20319
This happened because the user that executes the symfony process component is different than my normal user which results in a totally different $PATH
which does not have the usual globals that I had set.
If you would like to read up on this you could check out this discussion:
https://github.com/symfony/symfony/issues/21591
Upvotes: 1
Reputation: 1419
Don't know for sure why this is happening, but you can skip platform requisites in composer with --ignore-platform-reqs
option.
if ($process->isSuccessful()) {
$process = new Process("cd {$directory} && composer install --ignore-platform-reqs");
$process->run(function ($type, $buffer) {
if (Process::ERR === $type) {
Log::info($buffer);
} else {
Log::info($buffer);
}
});
}
Upvotes: 1