Edit report at https://bugs.php.net/bug.php?id=63028&edit=1
ID: 63028 Comment by: james dot turner dot phpninja at gmail dot com Reported by: james dot turner dot phpninja at gmail dot com Summary: Include inside Phar with "./" prefix fails to include correctly 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: While I might concur and say that this is not a "bug" as such, what i'm getting at is the fact that using "./include/a/file.php" IS valid syntax for a file include path. It works in normal PHP land, but it does not work within a Phar archive. The issue is that I have an external library, which I wish to package up for deployment, but i'm prohibited from doing so because the library uses these "./" prefix notations on all their include paths. I do NOT want to alter the whole library and change all include paths to use a different relative syntax for file paths as this will then lead to inconsistency between the source and the version I'm using. Given that phar archives can intercept file path related calls should it not be able to resolve "." to be the path relative to the file invoked from within the phar archive? I still believe this to be a problem... Previous Comments: ------------------------------------------------------------------------ [2012-09-07 09:12:37] larue...@php.net 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' ------------------------------------------------------------------------ [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