Edit report at https://bugs.php.net/bug.php?id=61317&edit=1
ID: 61317
User updated by: staff at pro-unreal dot de
Reported by: staff at pro-unreal dot de
Summary: phar locations in include_path are ignored
Status: Open
Type: Bug
Package: PHAR related
Operating System: Linux
PHP Version: 5.3.10
Block user comment: N
Private report: N
New Comment:
I am not sure if ':' as PATH_SEPARATOR is the problem, but it works when
calling include/require from a file inside a phar.
By the way ZendFramework for example uses preg_split to avoid the explode(':',
$path) issue.
Previous Comments:
------------------------------------------------------------------------
[2012-06-20 07:31:00] stawi at plusnet dot pl
Isnt this related to fact that PATH_SEPARATOR is ":" which occurs in "phar://" ?
Try this:
set_include_path('phar://my.phar/lib:/usr/share/php');
var_export(explode(PATH_SEPARATOR, get_include_path()));
And the result is: array(
0 => 'phar',
1 => '//my.phar/lib',
2 => '/usr/share/php',
)
Not shure how it works inside, but for PHP programmer it inconvenient...
Some frameworks uses autoloaders which do explode() and then foreach array to
find file.
I know that changing PATH_SEPARATOR to other char can break a lot of code where
it was hardcored as ":", but if constans exists one should use it ;)
------------------------------------------------------------------------
[2012-03-07 10:16:29] staff at pro-unreal dot de
Also applies for full phar URLs (Assuming the phar exists and contains the
described files).
Replace phar://my.phar/lib with full url like phar:///tmp/my.phar/lib
------------------------------------------------------------------------
[2012-03-07 10:11:28] staff at pro-unreal dot de
Description:
------------
When including files from outside a Phar all phar:// locations in include path
are ignored.
Test script:
---------------
include_path = phar://my.phar/lib:/usr/share/php
phar://my.phar/lib/Foo/Bar.php:
<?php
echo 'YES: ' . __FILE__;
?>
/usr/share/php/Foo/Bar.php
<?php
echo 'You should not see this!'
?>
Test /tmp/test.php:
<?php
include 'Foo/Bar.php'
?>
php -d include_path='phar://my.phar/lib:/usr/share/php' /tmp/test.php
Expected result:
----------------
Output should be:
YES: phar://my.phar/lib/Foo/Bar.php
Actual result:
--------------
Output is:
You should not see this!
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=61317&edit=1