I am struggeling with a quite strange problem within ZendStudio. Including or requiring files inside a phar archive using the phar extensions phar:// stream wrapper will not work from within ZendStudio.
Here is what I have done.
Given the following file structure:
phar/Test.php
pharbuilder.php
usephar.php
With the following content:
phar/Test.php:
class Test {}
pharbuilder.php:
$phar = new Phar(__DIR__ . '/test.phar');
$phar->buildFromDirectory(__DIR__ . '/phar/');
usephar.php:
var_dump(file_exists('phar://' . __DIR__ . '/test.phar/Test.php'));
include('phar://' . __DIR__ . '/test.phar/Test.php');
$test = new Test();
var_dump($test);
Now, if you first run the pharbuilder.php in ZendStudio (ZS 8: right click on file, run as PHP Script) the phar file (test.phar) will be successfully created (before running it, you have to add the ini option phar.readonly=0
to the corresponding php.ini). However, running the usephar.php inside ZS, will result in an error.
bool(true)
Warning: include(): Failed opening 'phar:///somepath/test.phar/Test.php' for inclusion
So obviously, the file can be found, but it cannot be included. I can also access the content of the Test.php within the file using file_get_contents('phar://' . __DIR__ . '/test.phar/Test.php')
Also, I noticed that this will not happen, if I modify the run configuration for this script and disable the checkbox "Display debug information when running". So I assume it has something to do with the ZendDebugger, but I'm not quite sure.
When I run the same scripts from a console, everything works just fine.
I tried this with ZendStudio 8 and 10 and with all in ZS provided php versions (5.4.11, 5.3.21, 5.3.3 all in CGI and CLI).
Since I could not find anybody else with the same problem, I assume that I am doing something wrong and am open to any suggestions. Maybe some secret php.ini directive or something like this.