Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit b10fc89

Browse files
router now compatible with Slim 3
1 parent e466d39 commit b10fc89

File tree

4 files changed

+22
-5
lines changed

4 files changed

+22
-5
lines changed

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@
77
/drupal8
88
/npm-debug.log
99
/sites
10+
/slim

‎README.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,10 @@ return $php_web_server->listen();
103103

104104
# Notes
105105
I've tested this with the following php frameworks:
106+
* Slim 3 ( **the newest addition to this list** )
106107
* Yii2
107108
* CodeIgniter 3
108-
* Wordpress
109+
* Wordpress 4
109110
* Drupal 7 and 8
110111

111112
On the first request sent to router.php, it will attempt to download and create mimes.json, if that fails, you can find mimes.json in ./src/ and copy it next to router.php

‎package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"start-wordpress48": "php -d max_execution_time=280 -S 0.0.0.0:9004 -t ./wordpress48 src/router.php",
1212
"start-drupal7": "php -d max_execution_time=280 -S 0.0.0.0:9005 -t ./drupal7 src/router.php",
1313
"start-drupal8": "php -d max_execution_time=280 -S 0.0.0.0:9006 -t ./drupal8 src/router.php",
14+
"start-slim": "php -d max_execution_time=280 -S 0.0.0.0:9007 -t ./slim/public src/router.php",
1415
"test-router-path": "node ./test/routerPath.js",
1516
"deployDev": "git add -A && git commit -a -m \"deploy dev changes\" && npm version patch && git pull --progress -v --no-rebase \"origin\" && git push --tags --progress \"origin\" master:master"
1617
},

‎src/router.class.php‎

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ function process_request()
252252

253253
$this->favicon();
254254

255-
header($_SERVER['SERVER_PROTOCOL'].' 404 Not Found');
255+
header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found');
256256
$this->http_status = 404;
257257

258258
} else {
@@ -271,7 +271,7 @@ function process_request()
271271

272272
if (@strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) == $this->last_modified || $this->eTagHeader == $this->eTag) {
273273

274-
header($_SERVER['SERVER_PROTOCOL'].' 304 Not Modified');
274+
header($_SERVER['SERVER_PROTOCOL'] . ' 304 Not Modified');
275275
$this->http_status = 304;
276276

277277
} else {
@@ -651,11 +651,25 @@ function fix_path_info()
651651
/**
652652
* Drupal 7 - default:
653653
* - /user must show /user/ page - fix
654+
* Slim 3 - will enable if DRUPAL_ROOT is not found in your index.php
654655
*/
655-
$this->fix_url_rewrite();
656+
$readFile = fopen($_SERVER['DOCUMENT_ROOT'] . '/' . $this->indexPath, "r");
657+
$isDrupal = false;
658+
if ($readFile) {
659+
while (!feof($readFile) && $isDrupal == false) {
660+
$buffer = fread($readFile, 4096);
661+
if (strstr($buffer, 'DRUPAL_ROOT') !== FALSE) {
662+
$isDrupal = true;
663+
}
664+
}
665+
fclose($readFile);
666+
}
656667

657-
}
668+
if ($isDrupal) {
669+
$this->fix_url_rewrite();
670+
}
658671

672+
}
659673

660674
$_SERVER['PHP_SELF'] = $_SERVER['SCRIPT_NAME'] . (isset($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : "");
661675

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /