8000 feature #13105 [FrameworkBundle] added a test router for the built-in… · symfony/symfony@f260186 · GitHub
[go: up one dir, main page]

Skip to content 8000

Commit f260186

Browse files
committed
feature #13105 [FrameworkBundle] added a test router for the built-in web server (fabpot)
This PR was submitted for the 2.3 branch but it was merged into the 2.7 branch instead (closes #13105). Discussion ---------- [FrameworkBundle] added a test router for the built-in web server | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #9995 | License | MIT | Doc PR | n/a #9995 describes a very valid use case. Not sure if this should be merged into 2.7 only... now that I think about it, probably :) Commits ------- 77e27b7 [FrameworkBundle] added a test router for the buil-in web server
2 parents 550ca9d + 77e27b7 commit f260186

File tree

2 files changed

+33
-2
lines changed

2 files changed

+33
-2
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ protected function configure()
6868
6969
<info>%command.full_name% --router=app/config/router.php</info>
7070
71-
Specifing a router script is required when the used environment is not "dev" or
72-
"prod".
71+
Specifing a router script is required when the used environment is not "dev",
72+
"prod", or "test".
7373
7474
See also: http://www.php.net/manual/en/features.commandline.webserver.php
7575
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
/*
13+
* This file implements rewrite rules for PHP built-in web server.
14+
*
15+
* See: http://www.php.net/manual/en/features.commandline.webserver.php
16+
*
17+
* If you have custom directory layout, then you have to write your own router
18+
* and pass it as a value to 'router' option of server:run command.
19+
*
20+
* @author: Michał Pipa <michal.pipa.xsolve@gmail.com>
21+
* @author: Albert Jessurum <ajessu@gmail.com>
22+
*/
23+
24+
if (is_file($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR.$_SERVER['SCRIPT_NAME'])) {
25+
return false;
26+
}
27+
28+
$_SERVER = array_merge($_SERVER, $_ENV);
29+
$_SERVER['SCRIPT_FILENAME'] = $_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR.'app_test.php';
30+
31+
require 'app_test.php';

0 commit comments

Comments
 (0)
0