|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #75647 `-t dir` changed behavior when combined with a router file
Submitted: 2017-12-07 15:09 UTC Modified: 2017-12-07 15:36 UTC
From: martin dot st at wolke7 dot net Assigned:
Status: Duplicate Package: Built-in web server
PHP Version: 7.1.12 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: martin dot st at wolke7 dot net
New email:
PHP Version: OS:


 [2017-12-07 15:09 UTC] martin dot st at wolke7 dot net
This is my first bug report to PHP, so please don't be mad at me. 

The following command used to work fine but stopped working in PHP 7.1.12
`php -S localhost:8000 -t directory directory/router.php`

It seems like somebody changed the way relative paths are handled when using the `-t` option and a router file at the same time. 

This statement also shows how this was working 3 months ago:

I think it might be related to the following commit, but I'm not very sure (I'm not a C developer):;a=commit;h=816758eda2bcdd69ba505fb6bbb79124a7bf2254

What actually happens

Starting the server works nicely:

$ php -S localhost:8000 -t directory directory/router.php
PHP 7.1.12 Development Server started at Thu Dec  7 15:00:15 2017
Listening on http://localhost:8000
Document root is [/home/myuser/mycode/directory]
Press Ctrl-C to quit.

When a request comes in, I get a message like the following (both in the result and in the server output):
[Thu Dec  7 15:00:21 2017] PHP Warning:  Unknown: failed to open stream: No such file or directory in Unknown on line 0
[Thu Dec  7 15:00:21 2017] PHP Fatal error:  Unknown: Failed opening required '/home/myuser/mycode/directory/directory/router.php' (include_path='.:/home/rof/.phpenv/versions/7.1.12/lib/php/pear') in Unknown on line 0


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2017-12-07 15:22 UTC]
-Status: Open +Status: Duplicate
 [2017-12-07 15:22 UTC]
That is indeed the right commit.

However it's more or less an intentional change: the router script is now relative to the document root and not the current directory. An absolute path will work too, of course. See bug #75604.

$ php -S localhost:8000 -t directory router.php
$ php -S localhost:8000 -t directory `pwd`/directory/router.php
 [2017-12-07 15:26 UTC]
No, not "more or less". It is intentional and the commit clearly shows it as such.
 [2017-12-07 15:36 UTC]
@requinix: The commit shows that this was an unintended side-effect of another fix. It should be reverted, because it's an unnecessary BC break for a case where the new behavior doesn't even make sense. Paths provided on the CLI should be interpreted relative to the CLI CWD...
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Tue Nov 30 09:03:35 2021 UTC