@@ -128,6 +128,27 @@ environment variables using the second argument of the ``run()``,
128128 // On both Unix-like and Windows
129129 $process->run(null, ['MESSAGE' => 'Something to output']);
130130
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+
131152Getting real-time Process Output
132153--------------------------------
133154
0 commit comments