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

Commitd838ba6

Browse files
committed
Merge branch '5.0'
* 5.0: Update paragraph about portable command lines
2 parents39efd86 +cc22936 commitd838ba6

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

‎components/process.rst

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ Using Features From the OS Shell
107107

108108
Using array of arguments is the recommended way to define commands. This
109109
saves you from any escaping and allows sending signals seamlessly
110-
(e.g. to stop processesbefore completion)::
110+
(e.g. to stop processeswhile they run)::
111111

112112
$process = new Process(['/path/command', '--option', 'argument', 'etc.']);
113113
$process = new Process(['/path/to/php', '--define', 'memory_limit=1024M', '/path/to/script.php']);
@@ -134,6 +134,17 @@ environment variables using the second argument of the ``run()``,
134134
// On both Unix-like and Windows
135135
$process->run(null, ['MESSAGE' => 'Something to output']);
136136

137+
If you prefer to create portable commands that are independent from the
138+
operating system, you can write the above command as follows::
139+
140+
// works the same on Windows , Linux and macOS
141+
$process = Process::fromShellCommandline('echo "${:MESSAGE}"');
142+
143+
Portable commands require using a syntax that is specific to the component: when
144+
enclosing a variable name into ``"{$:`` and ``}"`` exactly, the process object
145+
will replace it with its escaped value, or will fail if the variable is not
146+
found in the list of environment variables attached to the command.
147+
137148
Setting Environment Variables for Processes
138149
-------------------------------------------
139150

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp