Bug #63028 [Opn->Nab]: Include inside Phar with "./" prefix fails to include correctly
| From: | laruence@php.net | Date: | Fri, 07 Sep 2012 09:12:37 +0000 |
| Subject: | Bug #63028 [Opn->Nab]: Include inside Phar with "./" prefix fails to include correctly | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-173229@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=63028&edit=1
ID: 63028
Updated by: laruence@php.net
Reported by: james dot turner dot phpninja at gmail dot com
Summary: Include inside Phar with "./" prefix fails to
include correctly
-Status: Open
+Status: Not a bug
Type: Bug
Package: PHAR related
Operating System: Ubuntu 12
PHP Version: 5.3.16
Block user comment: N
Private report: N
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
you should make your index.php like(which will use the include_path):
<?php
require_once 'includes/bootstrap.php'
Previous Comments:
------------------------------------------------------------------------
[2012-09-07 08:57:54] james dot turner dot phpninja at gmail dot com
Description:
------------
When including a file from another file within a phar build, that has a ./ prefix, e.g. include_once
'./my/other/file.php' a "failed to open stream: No such file or directory in
phar" warning is thrown followed by a Fatal error "PHP Fatal error: require_once():
Failed opening required './my/other/file.php"
The test script below contains 3 files required to produce the same output.
structure:
.
/src
/src/index.php
/src/includes/bootstrap.php
package.php
Test script:
---------------
// package.php
<?php
if(!file_exists('test.phar')){
try {
$phar = new Phar('test.phar');
$phar->buildFromDirectory('src');
$phar->setStub($phar->createDefaultStub());
} catch(PharException $e){
echo $e->getMessage();
}
} else {
require_once ('phar://test.phar');
}
// src/index.php
<?php
require_once './includes/bootstrap.php'
// src/includes/bootstrap.php
<?
echo "hello world";
Expected result:
----------------
hello world
Actual result:
--------------
/usr/bin/php /workspace/PharTest/package.php
PHP Warning: require_once(./includes/bootstrap.php): failed to open stream: No such file or
directory in phar:///workspace/PharTest/test.phar/index.php on line 3
PHP Stack trace:
PHP 1. {main}() /workspace/PharTest/package.php:0
PHP 2. require_once() /workspace/PharTest/package.php:12
PHP 3. include() /workspace/PharTest/test.phar:9
PHP Fatal error: require_once(): Failed opening required './includes/bootstrap.php'
(include_path='phar:///workspace/PharTest/test.phar:.:/usr/share/php:/usr/share/pear') in
phar:///workspace/PharTest/test.phar/index.php on line 3
PHP Stack trace:
PHP 1. {main}() /workspace/PharTest/package.php:0
PHP 2. require_once() /workspace/PharTest/package.php:12
PHP 3. include() /workspace/PharTest/test.phar:9
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=63028&edit=1