Skip to content

Commit d582690

Browse files
crynoboneStyleCIBotmpociot
authored
[11.x] Allows Laravel Framework to correctly resolve PHP binary when running via Laravel Herd (#52791)
* wip Signed-off-by: Mior Muhammad Zaki <[email protected]> * wip Signed-off-by: Mior Muhammad Zaki <[email protected]> * wip Signed-off-by: Mior Muhammad Zaki <[email protected]> * Apply fixes from StyleCI * wip Signed-off-by: Mior Muhammad Zaki <[email protected]> * Apply fixes from StyleCI * wip Signed-off-by: Mior Muhammad Zaki <[email protected]> * Update src/Illuminate/Support/functions.php Co-authored-by: Marcel Pociot <[email protected]> * Apply fixes from StyleCI --------- Signed-off-by: Mior Muhammad Zaki <[email protected]> Co-authored-by: StyleCI Bot <[email protected]> Co-authored-by: Marcel Pociot <[email protected]>
1 parent 0d0f55f commit d582690

File tree

8 files changed

+48
-8
lines changed

8 files changed

+48
-8
lines changed

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@
133133
"src/Illuminate/Filesystem/functions.php",
134134
"src/Illuminate/Foundation/helpers.php",
135135
"src/Illuminate/Log/functions.php",
136+
"src/Illuminate/Support/functions.php",
136137
"src/Illuminate/Support/helpers.php"
137138
],
138139
"psr-4": {

src/Illuminate/Console/Application.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
use Symfony\Component\Console\Input\InputOption;
1717
use Symfony\Component\Console\Input\StringInput;
1818
use Symfony\Component\Console\Output\BufferedOutput;
19-
use Symfony\Component\Process\PhpExecutableFinder;
19+
20+
use function Illuminate\Support\php_binary;
2021

2122
class Application extends SymfonyApplication implements ApplicationContract
2223
{
@@ -84,7 +85,7 @@ public function __construct(Container $laravel, Dispatcher $events, $version)
8485
*/
8586
public static function phpBinary()
8687
{
87-
return ProcessUtils::escapeArgument((new PhpExecutableFinder)->find(false) ?: 'php');
88+
return ProcessUtils::escapeArgument(php_binary());
8889
}
8990

9091
/**

src/Illuminate/Foundation/Console/InteractsWithComposerPackages.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
namespace Illuminate\Foundation\Console;
44

5-
use Symfony\Component\Process\PhpExecutableFinder;
65
use Symfony\Component\Process\Process;
76

7+
use function Illuminate\Support\php_binary;
8+
89
trait InteractsWithComposerPackages
910
{
1011
/**
@@ -39,6 +40,6 @@ protected function requireComposerPackages(string $composer, array $packages)
3940
*/
4041
protected function phpBinary()
4142
{
42-
return (new PhpExecutableFinder())->find(false) ?: 'php';
43+
return php_binary();
4344
}
4445
}

src/Illuminate/Queue/Listener.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
namespace Illuminate\Queue;
44

55
use Closure;
6-
use Symfony\Component\Process\PhpExecutableFinder;
76
use Symfony\Component\Process\Process;
87

8+
use function Illuminate\Support\php_binary;
9+
910
class Listener
1011
{
1112
/**
@@ -61,7 +62,7 @@ public function __construct($commandPath)
6162
*/
6263
protected function phpBinary()
6364
{
64-
return (new PhpExecutableFinder)->find(false) ?: 'php';
65+
return php_binary();
6566
}
6667

6768
/**

src/Illuminate/Support/Composer.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
use Illuminate\Filesystem\Filesystem;
77
use RuntimeException;
88
use Symfony\Component\Console\Output\OutputInterface;
9-
use Symfony\Component\Process\PhpExecutableFinder;
109
use Symfony\Component\Process\Process;
1110

1211
class Composer
@@ -204,7 +203,7 @@ protected function findComposerFile()
204203
*/
205204
protected function phpBinary()
206205
{
207-
return (new PhpExecutableFinder)->find(false) ?: 'php';
206+
return php_binary();
208207
}
209208

210209
/**
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
namespace Illuminate\Support\Process;
4+
5+
use Symfony\Component\Process\PhpExecutableFinder as SymfonyPhpExecutableFinder;
6+
7+
class PhpExecutableFinder extends SymfonyPhpExecutableFinder
8+
{
9+
/**
10+
* Finds The PHP executable.
11+
*/
12+
#[\Override]
13+
public function find(bool $includeArgs = true): string|false
14+
{
15+
if ($herdPath = getenv('HERD_HOME')) {
16+
return (new ExecutableFinder)->find('php', false, [implode(DIRECTORY_SEPARATOR, [$herdPath, 'bin'])]);
17+
}
18+
19+
return parent::find($includeArgs);
20+
}
21+
}

src/Illuminate/Support/composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"Illuminate\\Support\\": ""
3838
},
3939
"files": [
40+
"functions.php",
4041
"helpers.php"
4142
]
4243
},

src/Illuminate/Support/functions.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
namespace Illuminate\Support;
4+
5+
use Illuminate\Support\Process\PhpExecutableFinder;
6+
7+
/**
8+
* Determine the PHP Binary.
9+
*
10+
* @return string
11+
*/
12+
function php_binary()
13+
{
14+
return (new PhpExecutableFinder)->find(false) ?: 'php';
15+
}

0 commit comments

Comments
 (0)