Including new autoloader when running in PHAR
I have a tool I'm writing and want to bundle it up with box.
It has a spot where it evals code, but before that it must include a new autoloader for the code that will be evaled, so the code finds classes and all that jazz properly when being evaled.
Assume I built a PHAR and I wish to run that PHAR against the codebase I built it from.
$ box build
$ bin/mytool.phar command ./
> PHP Fatal error: Cannot redeclare composerRequiref0c22e411e267794e39d513db52f6d38()
(previously declared in phar:///mytool.phar/vendor/composer/autoload_real.php:54)
in /home/ojrask/project/mytool/vendor/composer/autoload_real.php on line 63
In the PHP-Scoper documentation it states that Box has some trick to avoid this situation, but I can't find anything related to it. I also dumped the "working copy" autoloader and tried to run the Phar but I get the same error.
If I run the PHAR against some other codebase (e.g. not against itself) then the autoloading thingy seems to work normally.
Usually, Box tries to dump the autoloader before bundling the code in the PHAR. As a result, the autoloader within the PHAR should be unique. When using PHP-Scoper, dumping the autoloader is necessary for the scoping to work, but with Box, it already does it so you don't have any extra action to take (except if you explicitly request to not dump it).
You should be able to get more information by compiling using --debug. It will create a .box_dump directory or something with the extracted PHAR + a configuration dump.
Okay, will have to see what the config and runtime dumps say.
Any update @rask ?
Sorry, been busy lately with other projects, I will set a reminder to get back to you on this.
@rask feel free to open a new issue if you still run into a problem :)