File tree 1 file changed +21
-0
lines changed
Filter options
1 file changed +21
-0
lines changed
Original file line number Diff line number Diff line change @@ -128,6 +128,27 @@ environment variables using the second argument of the ``run()``,
128
128
// On both Unix-like and Windows
129
129
$process->run(null, ['MESSAGE' => 'Something to output']);
130
130
131
+ Setting Environment Variables for Processes
132
+ -------------------------------------------
133
+
134
+ The constructor of the :class: `Symfony\\ Component\\ Process\\ Process ` class and
135
+ all of its methods related to executing processes (``run() ``, ``mustRun() ``,
136
+ ``start() ``, etc.) allow passing an array of environment variables to set while
137
+ running the process::
138
+
139
+ $process = new Process(['...'], null, ['ENV_VAR_NAME' => 'value']);
140
+ $process = Process::fromShellCommandline('...', null, ['ENV_VAR_NAME' => 'value']);
141
+ $process->run(null, ['ENV_VAR_NAME' => 'value']);
142
+
143
+ In addition to the env vars passed explicitly, processes inherit all the env
144
+ vars defined in your system. You can prevent this by setting to ``false `` the
145
+ env vars you want to remove::
146
+
147
+ $process = new Process(['...'], null, [
148
+ 'APP_ENV' => false,
149
+ 'SYMFONY_DOTENV_VARS' => false,
150
+ ]);
151
+
131
152
Getting real-time Process Output
132
153
--------------------------------
133
154
You can’t perform that action at this time.
0 commit comments