Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

stephan-v's avatar

Symfony process component points to wrong PHP version

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. I have installed php through homebrew and it seems that PHP 5.6.25 is the default macOS sierra php version. Any confirmation on this would be nice.

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.

0 likes
0 replies

Please or to participate in this conversation.