| 
        php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits             
             [2012-09-07 09:12 UTC] laruence@php.net
  [2012-09-07 09:12 UTC] laruence@php.net
 
-Status: Open
+Status: Not a bug
  [2012-09-07 10:02 UTC] james dot turner dot phpninja at gmail dot com
  [2012-09-07 10:07 UTC] laruence@php.net
  [2012-09-08 15:22 UTC] james dot turner dot phpninja at gmail dot com
  | 
    |||||||||||||||||||||||||||
            
                 
                Copyright © 2001-2025 The PHP GroupAll rights reserved.  | 
        Last updated: Tue Nov 04 04:00:01 2025 UTC | 
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