Skip to content

Commit

Permalink
feature #28303 [Process] Add relative path support for PHP_BINARY env…
Browse files Browse the repository at this point in the history
… var of PhpExecutableFinder (maidmaid)

This PR was merged into the 4.2-dev branch.

Discussion
----------

[Process] Add relative path support for PHP_BINARY env var of PhpExecutableFinder

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | /
| License       | MIT
| Doc PR        | /

At the moment, only the absolute path for PHP_BINARY env var works, for instance :

```
$ PHP_BINARY=/usr/bin/php7.2 php bin/console server:run
[OK] Server listening on http://127.0.0.1:8000

$ PHP_BINARY=php7.2 php bin/console server:run
[ERROR] Unable to find the PHP binary.
```

This PR makes possible the second command.

Commits
-------

52ed988 Add relative path support for PHP_BINARY env var of PhpExecutableFinder
  • Loading branch information
fabpot committed Sep 4, 2018
2 parents a0e21f8 + 52ed988 commit 2738d00
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/Symfony/Component/Process/PhpExecutableFinder.php
Expand Up @@ -37,7 +37,14 @@ public function find($includeArgs = true)
{
if ($php = getenv('PHP_BINARY')) {
if (!is_executable($php)) {
return false;
$command = '\\' === \DIRECTORY_SEPARATOR ? 'where' : 'command -v';
if ($php = strtok(exec($command.' '.escapeshellarg($php)), PHP_EOL)) {
if (!is_executable($php)) {
return false;
}
} else {
return false;
}
}

return $php;
Expand Down

0 comments on commit 2738d00

Please sign in to comment.