From 77e27b7628830d0405d432c8f83dd58fec479c6f Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 24 Dec 2014 16:11:15 +0100 Subject: [PATCH] [FrameworkBundle] added a test router for the buil-in web server --- .../Command/ServerRunCommand.php | 4 +-- .../Resources/config/router_test.php | 31 +++++++++++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 src/Symfony/Bundle/FrameworkBundle/Resources/config/router_test.php diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php index 3b2efc139a2d..01a1e4da7ffd 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php @@ -68,8 +68,8 @@ protected function configure() %command.full_name% --router=app/config/router.php -Specifing a router script is required when the used environment is not "dev" or -"prod". +Specifing a router script is required when the used environment is not "dev", +"prod", or "test". See also: http://www.php.net/manual/en/features.commandline.webserver.php diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/router_test.php b/src/Symfony/Bundle/FrameworkBundle/Resources/config/router_test.php new file mode 100644 index 000000000000..5b020d5d2297 --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/router_test.php @@ -0,0 +1,31 @@ + + * + * 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 = array_merge($_SERVER, $_ENV); +$_SERVER['SCRIPT_FILENAME'] = $_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR.'app_test.php'; + +require 'app_test.php';