File tree Expand file tree Collapse file tree 2 files changed +33
-2
lines changed Expand file tree Collapse file tree 2 files changed +33
-2
lines changed Original file line number Diff line number Diff line change @@ -114,6 +114,8 @@ You can configure the options passed to the ``other_options`` argument of
114114 and ``suppress_errors ``) are only supported on Windows operating systems.
115115 Check out the `PHP documentation for proc_open() `_ before using them.
116116
117+ .. _process-using-features-from-the-os-shell :
118+
117119Using Features From the OS Shell
118120--------------------------------
119121
Original file line number Diff line number Diff line change @@ -2301,8 +2301,9 @@ will take care of creating a new process with the parameters you passed::
23012301
23022302 class CleanUpService
23032303 {
2304- public function __construct(private readonly MessageBusInterface $bus)
2305- {
2304+ public function __construct(
2305+ private readonly MessageBusInterface $bus,
2306+ ) {
23062307 }
23072308
23082309 public function cleanUp(): void
@@ -2313,6 +2314,34 @@ will take care of creating a new process with the parameters you passed::
23132314 }
23142315 }
23152316
2317+ A static factory :method: `Symfony\\ Component\\ Process\\ Messenger\\ RunProcessMessage::fromShellCommandline ` is also
2318+ available if you want to use features of your shell such as redirections or pipes::
2319+
2320+ use Symfony\Component\Messenger\MessageBusInterface;
2321+ use Symfony\Component\Process\Messenger\RunProcessMessage;
2322+
2323+ class CleanUpService
2324+ {
2325+ public function __construct(
2326+ private readonly MessageBusInterface $bus,
2327+ ) {
2328+ }
2329+
2330+ public function cleanUp(): void
2331+ {
2332+ $this->bus->dispatch(RunProcessMessage::fromShellCommandline('echo "Hello World" > var/log/hello.txt'));
2333+
2334+ // ...
2335+ }
2336+ }
2337+
2338+ For more information, see the
2339+ dedicated :ref: `Using Features From the OS Shell <process-using-features-from-the-os-shell >` documentation.
2340+
2341+ .. versionadded :: 7.3
2342+
2343+ The ``RunProcessMessage::fromShellCommandline() `` method was introduced in Symfony 7.3.
2344+
23162345Once handled, the handler will return a
23172346:class: `Symfony\\ Component\\ Process\\ Messenger\\ RunProcessContext ` which
23182347contains many useful information such as the exit code or the output of the
You can’t perform that action at this time.
0 commit comments