Sooner or later, we all face issues related to protecting the fruit of our intellectual labor. Here’s a way to protect your precious PHP code and improve the execution time of your PHP scripts.
> php --php-ini /etc/php5/apache2/php.ini -r "bcompiler_write_header();"OK : PHP Warning: bcompiler_write_header() expects at least 1 parameter, 0 given in Command line code on line 1KO : PHP Fatal error: Call to undefined function bcompiler_write_header() in Command line code on line 1
If you get a KO, you need to redo the procedure and make sure that pear-php is properly installed.
<?php// the path of the bytecode file that will be created later
$bytecode="bytecode.php";
// The source file
$codesource="code.php";
// creation of the compiled file
$fichierbytecode=fopen($bytecode, "w");
// writing the file header;
bcompiler_write_header($fichierbytecode);
// writing the body of the file:
bcompiler_write_file($fichierbytecode, $codesource);
// writing the footer of the file:
bcompiler_write_footer($fichierbytecode);
?>