Skip to content
This repository was archived by the owner on Sep 8, 2021. It is now read-only.
This repository was archived by the owner on Sep 8, 2021. It is now read-only.

Value of PHP_SELF when router script is in task subdirectory #11

@andybee

Description

@andybee

In our projects the index.php is typically in a src folder inside the task. We've set the handler as src/index.php and this successfully executes with the PHP layer.

However, when PHP's built-in web server is run and the router is supplied in a sub-directory (e.g. php -S 0:8080 src/index.php), the value of PHP_SELF becomes the path of the URL called, rather than /src/index.php/foo/bar etc.

If you run the code from the root (e.g. php -S 0:8080 index.php) this problem does not exist.

I'm not sure if this behaviour is intentional or not, and that ultimately it could be a PHP issue rather than the layer, but currently it breaks the behaviour of popular routing engines such as Slim as they attempt to strip PHP_SELF from the path before evaluating routes and, therefore, fall over when it's value is actually the path.

Just wondering if anyone else had any better insight on this problem?

On way it could be resolved, and how I'm tempted to fix it up in our codebase for now, is to tweak the behaviour of bootstrap so that it can detect a subdirectory in _HANDLER and change to that path to run the script from PWD.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions