php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #55076 requires() fails in a subdirectory with the in-built webserver
Submitted: 2011-06-29 17:47 UTC Modified: 2011-07-05 21:55 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: sixd@php.net Assigned: moriyoshi (profile)
Status: Closed Package: Built-in web server
PHP Version: 5.4SVN-2011-06-29 (SVN) OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: sixd@php.net
New email:
PHP Version: OS:

 

 [2011-06-29 17:47 UTC] sixd@php.net
Description:
------------
Working-directory handling in the in-built webserver differs from Apache.  This 
makes some non-trivial apps impossible to use in the CLI webserver.

Extract the testcase (attached as a patch).
  $ tar -zxf wstest.tgz
  $ cd wstest
  $ php -n -S localhost:8000

In a browser, load http://localhost:8000/

The contents of index.html are displayed:
    Click here to load mydir/requiresfoo.php 

Click the link.

Test script:
---------------
See "patch" file

Expected result:
----------------
In mydir/requiresfoo.php
In mydir/foo.php


Actual result:
--------------
Warning: Unknown: failed to open stream: No such file or directory in Unknown on 
line 0
Fatal error: Unknown: Failed opening required './mydir/requiresfoo.php' 
(include_path='.:/home/cjones/php54-ic112/lib/php') in Unknown on line 0


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-06-29 17:51 UTC] sixd@php.net
The testcase files look like:
$ ls -lR wstest
wstest:
total 12
-rw-r--r-- 1 cjones cjones  318 2011-06-20 16:32 favicon.ico
-rw-r--r-- 1 cjones cjones  128 2011-06-29 14:33 index.html
drwxr-xr-x 2 cjones cjones 4096 2011-06-29 14:41 mydir

wstest/mydir:
total 8
-rw-r--r-- 1 cjones cjones 44 2011-06-29 14:28 foo.php
-rw-r--r-- 1 cjones cjones 75 2011-06-29 14:23 requiresfoo.php
$ cat wstest/index.html 
<html>
<body bgcolor="#ffffff">
<a href="./mydir/requiresfoo.php" >Click here to load mydir/requiresfoo.php</a>
</body>
</html>
$ cat wstest/mydir/requiresfoo.php 
<?php

echo "In mydir/requiresfoo.php<br />\n";

require('./foo.php');

?>
$ cat wstest/mydir/foo.php
<?php

echo "In mydir/foo.php<br />\n";

?>
 [2011-06-29 18:09 UTC] sixd@php.net
-Package: CGI related +Package: Other web server
 [2011-06-29 18:22 UTC] felipe@php.net
-Package: Other web server +Package: Built-in web server
 [2011-07-03 09:27 UTC] felipe@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: moriyoshi
 [2011-07-05 15:27 UTC] sixd@php.net
-Status: Assigned +Status: Closed
 [2011-07-05 15:27 UTC] sixd@php.net
This no longer reproduces.  It appears to have been fixed, most likely by the 
change for https://bugs.php.net/bug.php?id=55118 in http://svn.php.net/viewvc?
view=revision&revision=312855
 [2011-07-05 18:42 UTC] sixd@php.net
-Status: Closed +Status: Re-Opened
 [2011-07-05 18:42 UTC] sixd@php.net
Still occurs anytime a relative path is used, e.g.
php -S localhost:8000 -t wstest
or
php -S localhost:8000 -t .

A workaround is to use an absolute path, e.g:

php -S localhost:8000 -t `pwd`
 [2011-07-05 21:54 UTC] felipe@php.net
Automatic comment from SVN on behalf of felipe
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=312974
Log: - Fixed bug #55076 (requires() fails in a subdirectory with the in-built webserver)
 [2011-07-05 21:55 UTC] felipe@php.net
-Status: Re-Opened +Status: Closed
 [2011-07-05 21:55 UTC] felipe@php.net
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.

It should works now. :)
 [2012-04-18 09:50 UTC] laruence@php.net
Automatic comment on behalf of felipe
Revision: http://git.php.net/?p=php-src.git;a=commit;h=c10d14887099b3294816f9757e7f6ea55e4b0bfa
Log: - Fixed bug #55076 (requires() fails in a subdirectory with the in-built webserver)
 [2012-07-24 23:41 UTC] rasmus@php.net
Automatic comment on behalf of felipe
Revision: http://git.php.net/?p=php-src.git;a=commit;h=c10d14887099b3294816f9757e7f6ea55e4b0bfa
Log: - Fixed bug #55076 (requires() fails in a subdirectory with the in-built webserver)
 [2013-11-17 09:37 UTC] laruence@php.net
Automatic comment on behalf of felipe
Revision: http://git.php.net/?p=php-src.git;a=commit;h=c10d14887099b3294816f9757e7f6ea55e4b0bfa
Log: - Fixed bug #55076 (requires() fails in a subdirectory with the in-built webserver)
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue May 06 19:01:28 2025 UTC