diff --git a/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md b/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md
index 00d900d1c80c..b24e4ba04ae2 100644
--- a/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md
+++ b/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md
@@ -4,6 +4,7 @@ CHANGELOG
2.3.0
-----
+ * added possibility to run PHP built-in server in production environment
* added possibility to load the serializer component in the service container
* added route debug information when using the `router:match` command
* added `TimedPhpEngine`
diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php
index f62a15de2866..09ca54556bbb 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php
@@ -78,10 +78,16 @@ protected function configure()
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
+ $env = $this->getContainer()->getParameter('kernel.environment');
+
+ if ('prod' === $env) {
+ $output->writeln('Running PHP built-in server in production environment is NOT recommended!');
+ }
+
$router = $input->getOption('router') ?: $this
->getContainer()
->get('kernel')
- ->locateResource('@FrameworkBundle/Resources/config/router.php')
+ ->locateResource(sprintf('@FrameworkBundle/Resources/config/router_%s.php', $env))
;
$output->writeln(sprintf("Server running on %s\n", $input->getArgument('address')));
diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/router.php b/src/Symfony/Bundle/FrameworkBundle/Resources/config/router_dev.php
similarity index 100%
rename from src/Symfony/Bundle/FrameworkBundle/Resources/config/router.php
rename to src/Symfony/Bundle/FrameworkBundle/Resources/config/router_dev.php
diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/router_prod.php b/src/Symfony/Bundle/FrameworkBundle/Resources/config/router_prod.php
new file mode 100644
index 000000000000..4278b4bba15b
--- /dev/null
+++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/router_prod.php
@@ -0,0 +1,30 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+/*
+ * This file implements rewrite rules for PHP built-in web server.
+ *
+ * See: http://www.php.net/manual/en/features.commandline.webserver.php
+ *
+ * If you have custom directory layout, then you have to write your own router
+ * and pass it as a value to 'router' option of server:run command.
+ *
+ * @author: MichaĆ Pipa
+ * @author: Albert Jessurum
+ */
+
+if (is_file($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR.$_SERVER['SCRIPT_NAME'])) {
+ return false;
+}
+
+$_SERVER['SCRIPT_FILENAME'] = $_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR.'app.php';
+
+require 'app.php';