Skip to content

Commit 30176d4

Browse files
committed
feat: add router.php for composer serve command
1 parent c8259e0 commit 30176d4

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
"post-update-cmd": [
5454
"@auto-scripts"
5555
],
56-
"serve": "php -S 0.0.0.0:8000 -t test/sandbox/public",
56+
"serve": "php -S 0.0.0.0:8000 -t test/sandbox/public test/sandbox/public/router.php",
5757
"start-selenium": "./vendor/bin/selenium-server-standalone -p 4444 -Dwebdriver.chrome.driver=./vendor/bin/chromedriver",
5858
"test": "phpunit"
5959
},

test/sandbox/public/router.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
if (false === strpos($_SERVER['REQUEST_URI'], '.')
4+
|| is_file($_SERVER['DOCUMENT_ROOT'] . '/' . $_SERVER['SCRIPT_NAME'])
5+
) {
6+
return false;
7+
}
8+
9+
$_SERVER['SCRIPT_NAME'] = '/index.php';
10+
require __DIR__ . "/index.php";

0 commit comments

Comments
 (0)