@@ -107,7 +107,7 @@ Using Features From the OS Shell
107
107
108
108
Using array of arguments is the recommended way to define commands. This
109
109
saves you from any escaping and allows sending signals seamlessly
110
- (e.g. to stop processes before completion )::
110
+ (e.g. to stop processes while they run )::
111
111
112
112
$process = new Process(['/path/command', '--option', 'argument', 'etc.']);
113
113
$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()``,
134
134
// On both Unix-like and Windows
135
135
$process->run(null, ['MESSAGE' => 'Something to output']);
136
136
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
+
137
148
Setting Environment Variables for Processes
138
149
-------------------------------------------
139
150
0 commit comments