From 5cad296d72b6438d8f50783fa6240b880cb886cc Mon Sep 17 00:00:00 2001 From: Ricky Su Date: Tue, 14 Jan 2014 15:35:43 +0800 Subject: [PATCH 1/2] add hhvm server run support --- .../Command/ServerRunCommand.php | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php index 1d01e04c1296..de33a84a7352 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php @@ -92,6 +92,11 @@ protected function execute(InputInterface $input, OutputInterface $output) $output->writeln(sprintf("Server running on %s\n", $input->getArgument('address'))); + if (defined('HHVM_VERSION')) { + $this->executeWithHHVM($input, $output, $env); + return; + } + $builder = new ProcessBuilder(array(PHP_BINARY, '-S', $input->getArgument('address'), $router)); $builder->setWorkingDirectory($input->getOption('docroot')); $builder->setTimeout(null); @@ -101,4 +106,69 @@ protected function execute(InputInterface $input, OutputInterface $output) } }); } + + protected function executeWithHHVM(InputInterface $input, OutputInterface $output, $env) + { + list($ip, $port) = explode(':', $input->getArgument('address')); + $output->writeln(sprintf("Server(with HHVM) running on $ip:$port\n", $ip, $port)); + $docroot = realpath($input->getOption('docroot')); + $bootstrap = ('prod' === $env ? 'app.php' : 'app_dev.php'); + $config = <<setWorkingDirectory($docroot); + $builder->setTimeout(null); + $builder->getProcess()->run(function ($type, $buffer) use ($output, &$tmpfile) { + if (null !== $tmpfile) { + unlink($tmpfile); + $tmpfile = null; + } + if (OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) { + $output->write($buffer); + } + }); + } + } From 8aac1e26ce3e64852945be7fd89286e8c66e7c54 Mon Sep 17 00:00:00 2001 From: Ricky Su Date: Tue, 14 Jan 2014 18:34:40 +0800 Subject: [PATCH 2/2] put hhvm config in app/cache --- .../Bundle/FrameworkBundle/Command/ServerRunCommand.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php index de33a84a7352..88de4a0a2dda 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php @@ -155,16 +155,12 @@ protected function executeWithHHVM(InputInterface $input, OutputInterface $outpu } } EOF; - $tmpfile = tempnam(sys_get_temp_dir(), 'symfony_hhvm_config'); + $tmpfile = $this->getContainer()->get('kernel')->getCacheDir().DIRECTORY_SEPARATOR.'hhvm-server-'.md5($config).'.hdf'; file_put_contents($tmpfile, $config); $builder = new ProcessBuilder(array(PHP_BINARY, '-ms', "-c$tmpfile")); $builder->setWorkingDirectory($docroot); $builder->setTimeout(null); - $builder->getProcess()->run(function ($type, $buffer) use ($output, &$tmpfile) { - if (null !== $tmpfile) { - unlink($tmpfile); - $tmpfile = null; - } + $builder->getProcess()->run(function ($type, $buffer) use ($output) { if (OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) { $output->write($buffer); }