Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a613d23

Browse files
committed
Add binary location as option
See barryvdh#25 Default is php, null = autodetect.
1 parent 81c6296 commit a613d23

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

readme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ You should now be able to use the async driver in config/queue.php
3434
...
3535
'async' => array(
3636
'driver' => 'async',
37+
'binary' => 'php', // Optional: path to php binary, defaults to 'php'. Set to null to autodetect.
3738
),
3839
...
3940
}

src/AsyncQueue.php

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,14 @@
77

88
class AsyncQueue extends SyncQueue
99
{
10-
/** @var PhpExecutableFinder */
11-
protected $phpfinder;
10+
protected $binary;
1211

13-
public function __construct(){
14-
$this->phpfinder = new PhpExecutableFinder();
12+
public function __construct(array $config)
13+
{
14+
$this->binary = array_key_exists('binary', $config) ? $config['binary'] : 'phpauto';
15+
if (!$this->binary) {
16+
$this->binary = $this->getPhpBinary();
17+
}
1518
}
1619

1720
/**
@@ -80,16 +83,16 @@ protected function getCommand($jobId)
8083
$cmd = '%s artisan queue:async %d --env=%s';
8184
$cmd = $this->getBackgroundCommand($cmd);
8285

83-
$php = $this->getPhpBinary();
8486
$environment = $this->container->environment();
8587

86-
return sprintf($cmd, $php, $jobId, $environment);
88+
return sprintf($cmd, $this->binary, $jobId, $environment);
8789
}
8890

8991
protected function getPhpBinary()
9092
{
91-
$path = escapeshellarg($this->phpfinder->find(false));
92-
$args = implode(' ', $this->phpfinder->findArguments());
93+
$phpfinder = new PhpExecutableFinder();
94+
$path = escapeshellarg($phpfinder->find(false));
95+
$args = implode(' ', $phpfinder->findArguments());
9396
return trim($path.' '.$args);
9497
}
9598

src/Connectors/AsyncConnector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ class AsyncConnector implements ConnectorInterface
1616
*/
1717
public function connect(array $config)
1818
{
19-
return new AsyncQueue();
19+
return new AsyncQueue($config);
2020
}
2121
}

0 commit comments

Comments
 (0)