Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running from inside PHAR ? #10

Open
henrywood opened this issue Dec 5, 2018 · 2 comments
Open

Running from inside PHAR ? #10

henrywood opened this issue Dec 5, 2018 · 2 comments

Comments

@henrywood
Copy link

henrywood commented Dec 5, 2018

I am trying to get bcgen to work with PHAR files. I have added the compiled PHP files to the PHAR file (using their PHP extension within the PHAR file)

The stub of the PHP archive is:

#!/usr/bin/env php
<?php
Phar::mapPhar( 'app.phar' );
set_include_path( 'phar://app.phar' . PATH_SEPARATOR.';.');
require('phar://' . __FILE__ . '/app.php');
__HALT_COMPILER(); ?>`

The file app.php is in the root of the PHAR archive and is the version compiled by bcgen.

When I run the phar (on the commandline), all I get is some gibberish output (to STDOUT) and the process exits with exitcode 130 ?

My understanding is that bcgen extension will inspect the file which is included/required (ie. app.php) and then - if it is bytecode - then simply execute the bytecode - If it is not, then it will parse the included file normally ?

However it seems that what actually happens, is that the header of the PHAR file itself is checked and since that is obviously not a BCGEN header, processing is aborted.
If we could skip this check when running from a PHAR archive (from the commandline or when the PHAR is included within some other PHP file) and in this scenario only "react" to include/require/autoloading statements (ie. check if a file that is about to be included is bytecode or not - if it is, then run it - If it is not then compile it first and then run the resulting bytecode), then - in my humble opinion - we would have a way of adding minimal protection to PHAR files - useful when redistributing PHARs (since such a PHAR archive would then simply contain a number of files that are bytecode - except for the stub of course...) and that would - I think - make PHAR files even cooler and provide a most sought-after feature.

Please let me know what you think.

Thanks for your efforts for providing bcgen.

@nanosonde
Copy link
Collaborator

@henrywood
It might be that I have accidently removed the support for PHAR files.
Maybe you can study the OPcache code to see what is missing.

Personally I am about to abandon this project.
See here: #9 (comment)

@henrywood
Copy link
Author

@nanosonde Thanks for getting back to me !
I'll try to propose the change/idea to @vjardin then !

Also, thank you for your work on BCGen !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants