Commit 5aeccb5
committed
Fix value of
PHP's built-in web server sets the value of `$_SERVER['PHP_SELF']` differently
when the router script is in working directory versus a subdirectory of the
working directory. This breaks routing functionality in routing libraries such
as [Slim](https://www.slimframework.com).
When the script is in the working directory, the value of `PHP_SELF` is the
filename of the script, but when run from a parent directory of the script it
changes to being the path requested of the web server.
This commit changes `bootstrap` behaviour when referring to the Lambda handler.
If it refers to a script in a subdirectory of the task root, it changes the
`chdir` call to enter that directory before running the PHP internal web-server,
so that it can refer to the script filename as being in the working directory.
This poses no change to how the layer is configured or run, but `PHP_SELF` now
correctly refers to the filename and this solves the issue with Slim.
Resolves: stackery#11PHP_SELF when router script is in a subdirectory1 parent 2a7eb84 commit 5aeccb5
1 file changed
+5
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
21 | | - | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
22 | 25 | | |
23 | 26 | | |
24 | 27 | | |
| |||
0 commit comments