Next time in my life i see some bytecode after function __halt_compiler. In this case it's symfony installer. How to do that ? How to generate code which will be executable after __halt_compiler ?
I guess you mean https://symfony.com/installer, a PHAR archive that starts like this:
#!/usr/bin/env php
<?php
/**
* Generated by Box.
*
* @link https://github.com/herrera-io/php-box/
*/
if (class_exists('Phar')) {
Phar::mapPhar('default.phar');
require 'phar://' . __FILE__ . '/symfony';
}
__HALT_COMPILER(); ?>
Conceptually speaking, PHAR archives are not too different from self-extracting ZIP files (in fact ZIP is among the supported internal formats). The archive contains:
A stub, which is the short PHP script you can see.
A manifest with a description of the archive contentes
An archive with the contents themselves
An optional signature
The stub on top is a regular PHP script so the PHAR archive can run with the regular PHP interpreter rather than requiring a dedicated executable:
php foo.phar
This script block ends with __HALT_COMPILER(); to::
Prevent the rest of the file from being parsed and possibly executed as PHP code (the main script does all that's needed for the initial phase).
Populate the __COMPILER_HALT_OFFSET__
constant so the PHAR library can easily detect where archived data starts.
This scripts does three things:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With