Fixing Fatal PHP PharException without disabling your accelerator
Jan 11, 2017 under Linux Server
PHP phar feature is quite old now and widely used. Basically the phar extension provides a way to put entire PHP applications into a single file called a “phar” (PHP Archive) for easy distribution and installation.
If by any chance when included in your PHP code (either via Composer or via Phar) you get the following error Fatal error: PharException with message __HALT_COMPILER(); must be declared in a phar the issue can be due to your xcache (see reported PHP Fatal error on stackoverflow ) or by eaccelerator (see on eAccelerator github )
Check the full list of PHP accelerators for reference!
First solution indicated by RedBeanPHP 4 __HALT_COMPILER(); issue was to disable XCache (or other possible accelerator) which are not really up to date on supporting such Phar feature, see reported issue for accelerator
However, since your website may need such accelerators and your project (which may use old php code) cannot be easy adapted for new PHP versions, the easiest solution is to convert the phar file into multiple PHP files and include them in the classic style !
Some website even offer such Phar conversion, example: http://unphar.com/extract
Once you get the zip file, copy the hole directories and include them by using PHP 5 autoload feature:
You should have already after extracting the Phar archive such autoload.php file!
The hole functionally should be there, we tested already all steps!