Skip to content

Commit b7cd22c

Browse files
committed
bug #37000 Add meaningful message when using ProcessHelper and Process is not installed (l-vo)
This PR was submitted for the master branch but it was merged into the 3.4 branch instead. Discussion ---------- Add meaningful message when using ProcessHelper and Process is not installed | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | | License | MIT | Doc PR | When using the process helper without the `Process` component, a php fatal error is triggered (`PHP Fatal error: Uncaught Error: Class 'Symfony\Component\Process\Process' not found`). This PR adds a meaningful exception; allowing to display a console error message instead of a raw php fatal error. Commits ------- 3ab76e4 Add meaningful message when Process is not installed (ProcessHelper)
2 parents 03cad5a + 3ab76e4 commit b7cd22c

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/Symfony/Component/Console/Helper/ProcessHelper.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ class ProcessHelper extends Helper
3737
*/
3838
public function run(OutputInterface $output, $cmd, $error = null, callable $callback = null, $verbosity = OutputInterface::VERBOSITY_VERY_VERBOSE)
3939
{
40+
if (!class_exists(Process::class)) {
41+
throw new \LogicException('The Process helper requires the "Process" component. Install "symfony/process" to use it.');
42+
}
43+
4044
if ($output instanceof ConsoleOutputInterface) {
4145
$output = $output->getErrorOutput();
4246
}

0 commit comments

Comments
 (0)