8000 feature #10017 [FrameworkBundle] Add HHVM support for built-in web se… · symfony/symfony@887e6ff · GitHub
[go: up one dir, main page]

Skip to content

Commit 887e6ff

Browse files
committed
feature #10017 [FrameworkBundle] Add HHVM support for built-in web server (RickySu)
This PR was squashed before being merged into the 2.5-dev branch (closes #10017). Discussion ---------- [FrameworkBundle] Add HHVM support for built-in web server | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | no | License | MIT Using HHVM as built-in web server for development from console. ``` hhvm app/console server:run ``` Commits ------- 66798ba [FrameworkBundle] Add HHVM support for built-in web server
2 parents 2a15923 + 66798ba commit 887e6ff

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed

src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,11 @@ protected function execute(InputInterface $input, OutputInterface $output)
9292

9393
$output->writeln(sprintf("Server running on <info>%s</info>\n", $input->getArgument('address')));
9494

95+
if (defined('HHVM_VERSION')) {
96+
$this->executeWithHHVM($input, $output, $env);
97+
return;
98+
}
99+
95100
$builder = new ProcessBuilder(array(PHP_BINARY, '-S', $input->getArgument('address'), $router));
96101
$builder->setWorkingDirectory($input->getOption('docroot'));
97102
$builder->setTimeout(null);
@@ -101,4 +106,65 @@ protected function execute(InputInterface $input, OutputInterface $output)
101106
}
102107
});
103108
}
109+
110+
protected function executeWithHHVM(InputInterface $input, OutputInterface $output, $env)
111+
{
112+
list($ip, $port) = explode(':', $input->getArgument('address'));
113+
$output->writeln(sprintf("Server(with HHVM) running on <info>$ip:$port</info>\n", $ip, $port));
114+
$docroot = realpath($input->getOption('docroot'));
115+
$bootstrap = ('prod' === $env ? 'app.php' : 'app_dev.php');
116+
$config = <<<EOF
117+
Server {
118+
IP = $ip
119+
Port = $port
120+
SourceRoot = $docroot
121+
RequestTimeoutSeconds = -1
122+
RequestMemoryMaxBytes = -1
123+
}
124+
125+
VirtualHost {
126+
* {
127+
Pattern = .*
128+
RewriteRules {
129+
* {
130+
pattern = .?
131+
132+
# app bootstrap
133+
to = $bootstrap
134+
135+
# append the original query string
136+
qsa = true
137+
}
138+
}
139+
}
140+
}
141+
142+
StaticFile {
143+
Extensions {
144+
css = text/css
145+
gif = image/gif
146+
html = text/html
147+
jpe = image/jpeg
148+
jpeg = image/jpeg
149+
jpg = image/jpeg
150+
png = image/png
151+
tif = image/tiff
152+
tiff = image/tiff
153+
txt = text/plain
154+
php = text/plain
155+
}
156+
}
157+
EOF;
158+
$tmpfile = $this->getContainer()->get('kernel')->getCacheDir().DIRECTORY_SEPARATOR.'hhvm-server-'.md5($config).'.hdf';
159+
file_put_contents($tmpfile, $config);
160+
$builder = new ProcessBuilder(array(PHP_BINARY, '-ms', "-c$tmpfile"));
161+
$builder->setWorkingDirectory($docroot);
162+
$builder->setTimeout(null);
163+
$builder->getProcess()->run(function ($type, $buffer) use ($output) {
164+
if (OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) {
165+
$output->write($buffer);
166+
}
167+
});
168+
}
169+
104170
}

0 commit comments

Comments
 (0)
0