diff --git a/components/process.rst b/components/process.rst index f6c8837d2c3..7552537e82e 100644 --- a/components/process.rst +++ b/components/process.rst @@ -114,6 +114,8 @@ You can configure the options passed to the ``other_options`` argument of and ``suppress_errors``) are only supported on Windows operating systems. Check out the `PHP documentation for proc_open()`_ before using them. +.. _process-using-features-from-the-os-shell: + Using Features From the OS Shell -------------------------------- diff --git a/messenger.rst b/messenger.rst index 08209896ef4..6eb187af460 100644 --- a/messenger.rst +++ b/messenger.rst @@ -2301,8 +2301,9 @@ will take care of creating a new process with the parameters you passed:: class CleanUpService { - public function __construct(private readonly MessageBusInterface $bus) - { + public function __construct( + private readonly MessageBusInterface $bus, + ) { } public function cleanUp(): void @@ -2313,6 +2314,34 @@ will take care of creating a new process with the parameters you passed:: } } +A static factory :method:`Symfony\\Component\\Process\\Messenger\\RunProcessMessage::fromShellCommandline` is also +available if you want to use features of your shell such as redirections or pipes:: + + use Symfony\Component\Messenger\MessageBusInterface; + use Symfony\Component\Process\Messenger\RunProcessMessage; + + class CleanUpService + { + public function __construct( + private readonly MessageBusInterface $bus, + ) { + } + + public function cleanUp(): void + { + $this->bus->dispatch(RunProcessMessage::fromShellCommandline('echo "Hello World" > var/log/hello.txt')); + + // ... + } + } + +For more information, see the +dedicated :ref:`Using Features From the OS Shell ` documentation. + +.. versionadded:: 7.3 + + The ``RunProcessMessage::fromShellCommandline()`` method was introduced in Symfony 7.3. + Once handled, the handler will return a :class:`Symfony\\Component\\Process\\Messenger\\RunProcessContext` which contains many useful information such as the exit code or the output of the