Skip to content

Commit d89f552

Browse files
committed
IHF: call_in_background helper added.
1 parent 7e21181 commit d89f552

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

src/artisan.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
use Symfony\Component\Process\PhpExecutableFinder;
4+
use Symfony\Component\Process\ProcessUtils;
5+
6+
if (!function_exists('call_in_background')) {
7+
function call_in_background($command, $before = null, $after = null)
8+
{
9+
$parts = [];
10+
if (!empty($before)) {
11+
$parts[] = $before;
12+
}
13+
14+
$binary = ProcessUtils::escapeArgument((new PhpExecutableFinder)->find(false));
15+
if (defined('HHVM_VERSION')) {
16+
$binary .= ' --php';
17+
}
18+
$artisan = 'artisan';
19+
if (defined('ARTISAN_BINARY')) {
20+
$artisan = ProcessUtils::escapeArgument(ARTISAN_BINARY);
21+
}
22+
$parts[] = "{$binary} {$artisan} {$command}";
23+
24+
if (!empty($after)) {
25+
$parts[] = $after;
26+
}
27+
28+
$expression = implode(' && ', $parts);
29+
exec("({$expression}) > /dev/null 2>&1 &");
30+
}
31+
}

0 commit comments

Comments
 (0)