Skip to content

Commit 40472ac

Browse files
authored
Merge pull request stackery#12 from aiir/fix-PHP_SELF-value
Fix value of `PHP_SELF` when router script is in a subdirectory
2 parents 1fa196c + 5aeccb5 commit 40472ac

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

bootstrap

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,11 @@ function start_webserver() {
1717
case 0:
1818
// exec the command
1919
$HANDLER = getenv('_HANDLER');
20-
chdir('/var/task');
21-
exec("PHP_INI_SCAN_DIR=/opt/etc/php-7.1.d/:/var/task/php-7.1.d/ php -S localhost:8000 -c /var/task/php.ini -d extension_dir=/opt/lib/php/7.1/modules '$HANDLER'");
20+
$handler_components = explode('/', $HANDLER);
21+
$handler_filename = array_pop($handler_components);
22+
$handler_path = implode('/', array_merge(['/var/task'], $handler_components));
23+
chdir($handler_path);
24+
exec("PHP_INI_SCAN_DIR=/opt/etc/php-7.1.d/:/var/task/php-7.1.d/ php -S localhost:8000 -c /var/task/php.ini -d extension_dir=/opt/lib/php/7.1/modules '$handler_filename'");
2225
exit;
2326

2427
// return the child pid to parent

0 commit comments

Comments
 (0)