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
114
114
and ``suppress_errors ``) are only supported on Windows operating systems.
115
115
Check out the `PHP documentation for proc_open() `_ before using them.
116
116
117
+ .. _process-using-features-from-the-os-shell :
118
+
117
119
Using Features From the OS Shell
118
120
--------------------------------
119
121
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::
2301
2301
2302
2302
class CleanUpService
2303
2303
{
2304
- public function __construct(private readonly MessageBusInterface $bus)
2305
- {
2304
+ public function __construct(
2305
+ private readonly MessageBusInterface $bus,
2306
+ ) {
2306
2307
}
2307
2308
2308
2309
public function cleanUp(): void
@@ -2313,6 +2314,34 @@ will take care of creating a new process with the parameters you passed::
2313
2314
}
2314
2315
}
2315
2316
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
+
2316
2345
Once handled, the handler will return a
2317
2346
:class: `Symfony\\ Component\\ Process\\ Messenger\\ RunProcessContext ` which
2318
2347
contains 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