Support @php prefix for scripts to reuse the current PHP interpreter, fixes #5957
parent
9b0ddcd9dd
commit
b0000617cc
|
@ -249,3 +249,23 @@ resolve to whatever composer.phar is currently being used:
|
||||||
One limitation of this is that you can not call multiple composer commands in
|
One limitation of this is that you can not call multiple composer commands in
|
||||||
a row like `@composer install && @composer foo`. You must split them up in a
|
a row like `@composer install && @composer foo`. You must split them up in a
|
||||||
JSON array of commands.
|
JSON array of commands.
|
||||||
|
|
||||||
|
## Executing PHP scripts
|
||||||
|
|
||||||
|
To execute PHP scripts, you can use `@php` which will automatically
|
||||||
|
resolve to whatever php process is currently being used:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"scripts": {
|
||||||
|
"test": [
|
||||||
|
"@php script.php",
|
||||||
|
"phpunit"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
One limitation of this is that you can not call multiple commands in
|
||||||
|
a row like `@php install && @php foo`. You must split them up in a
|
||||||
|
JSON array of commands.
|
||||||
|
|
|
@ -233,6 +233,15 @@ class EventDispatcher
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (substr($exec, 0, 5) === '@php ') {
|
||||||
|
$finder = new PhpExecutableFinder();
|
||||||
|
$phpPath = $finder->find();
|
||||||
|
if (!$phpPath) {
|
||||||
|
throw new \RuntimeException('Failed to locate PHP binary to execute "'.$exec.'"');
|
||||||
|
}
|
||||||
|
$exec = $phpPath . ' ' . substr($exec, 5);
|
||||||
|
}
|
||||||
|
|
||||||
if (0 !== ($exitCode = $this->process->execute($exec))) {
|
if (0 !== ($exitCode = $this->process->execute($exec))) {
|
||||||
$this->io->writeError(sprintf('<error>Script %s handling the %s event returned with error code '.$exitCode.'</error>', $callable, $event->getName()));
|
$this->io->writeError(sprintf('<error>Script %s handling the %s event returned with error code '.$exitCode.'</error>', $callable, $event->getName()));
|
||||||
|
|
||||||
|
@ -460,7 +469,7 @@ class EventDispatcher
|
||||||
*/
|
*/
|
||||||
protected function isComposerScript($callable)
|
protected function isComposerScript($callable)
|
||||||
{
|
{
|
||||||
return '@' === substr($callable, 0, 1);
|
return '@composer ' === substr($callable, 0, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue