-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement PrependRunner - none of the drawbacks of the others
- Loading branch information
Showing
4 changed files
with
44 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
namespace Pogo\Runner; | ||
|
||
/** | ||
* Class AutoPrependRunner | ||
* @package Pogo\Runner | ||
* | ||
* Execute via 'php -d auto_prepend_file=$autoload $script;' | ||
*/ | ||
class PrependRunner { | ||
|
||
/** | ||
* @param string $autoloader | ||
* @param \Pogo\ScriptMetadata $scriptMetadata | ||
* @param array $cliArgs | ||
* @return int | ||
*/ | ||
public function run($autoloader, $scriptMetadata, $cliArgs) { | ||
$script = $scriptMetadata->file; | ||
|
||
$defines = \Pogo\Php::iniToArgv($scriptMetadata->ini + ['auto_prepend_file' => $autoloader]); | ||
$cmd = sprintf('POGO_SCRIPT=%s php %s %s', escapeshellarg($script), $defines, escapeshellarg($script)); | ||
|
||
if ($cliArgs) { | ||
$cmd .= ' ' . implode(' ', array_map('escapeshellarg', $cliArgs)); | ||
} | ||
// printf("[%s] Running command: $cmd\n", __CLASS__, $cmd); | ||
$process = proc_open($cmd, [STDIN, STDOUT, STDERR], $pipes); | ||
return proc_close($process); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters