8000 [Process] Add windows compatibility to Process component · symfony/symfony@f555c62 · GitHub
[go: up one dir, main page]

Skip to content

Commit f555c62

Browse files
committed
[Process] Add windows compatibility to Process component
1 parent c4e8ff7 commit f555c62

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

src/Symfony/Component/Process/Process.php

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class Process
3434
private $status;
3535
private $stdout;
3636
private $stderr;
37+
private $enhanceWindowsCompatibility = true;
3738

3839
/**
3940
* Exit codes translation table.
@@ -159,7 +160,13 @@ public function run($callback = null)
159160

160161
$descriptors = array(array('pipe', 'r'), array('pipe', 'w'), array('pipe', 'w'));
161162

162-
$process = proc_open($this->commandline, $descriptors, $pipes, $this->cwd, $this->env, $this->options);
163+
$commandline = $this->commandline;
164+
165+
if (defined('PHP_WINDOWS_VERSION_BUILD') && $this->enhanceWindowsCompatibility) {
166+
$commandline = 'cmd /V:ON /E:ON /C "'.$commandline.'"';
167+
}
168+
169+
$process = proc_open($commandline, $descriptors, $pipes, $this->cwd, $this->env, $this->options);
163170

164171
if (!is_resource($process)) {
165172
throw new \RuntimeException('Unable to launch a new process.');
@@ -431,4 +438,15 @@ public function setOptions(array $options)
431438
{
432439
$this->options = $options;
433440
}
441+
442+
public function getEnhanceWindowsCompatibility()
443+
{
444+
return $this->enhanceWindowsCompatibility;
445+
}
446+
447+
public function setEnhanceWindowsCompatibility($enhance)
448+
{
449+
$this->enhanceWindowsCompatibility = (Boolean) $enhance;
450+
}
451+
434452
}

0 commit comments

Comments
 (0)
0