Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Messenger][Process] addfromShellCommandLine() documentation#20681

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletionscomponents/process.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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
--------------------------------

Expand Down
33 changes: 31 additions & 2 deletionsmessenger.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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
Expand All@@ -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 <process-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
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp