Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP __halt_compiler not found

Tags:

php

I'm running a local server with PHP 5.6. I'm using a third party library which uses the function __halt_compiler. Once this function is reached I get the following error.

PHP Fatal error: Uncaught exception 'UnexpectedValueException' with message 'internal corruption of phar'. (__HALT_COMPILER(); not found)

All of my searches with the keywords phar and __halt_compiler have returned useless. Below are some details from printing phpinfo().

Phar: PHP Archive support => enabled
Phar EXT version => 2.0.2
Phar API version => 1.1.1
Phar-based phar archives => enabled
Tar-based phar archives => enabled
ZIP-based phar archives => enabled
gzip compression => enabled
bzip2 compression => enabled
OpenSSL support => enabled

phar.cache_list => no value => no value
phar.readonly => On => On
phar.require_hash => On => On

Does anyone know why I don't have this function and/or how I can acquire it.

Please let me know if there's more info I can provide.

like image 900
cnotethegr8 Avatar asked Sep 27 '22 05:09

cnotethegr8


1 Answers

Does anyone know why I don't have this function and/or how I can acquire it.

You came to the wrong conclusion. The error message does not say "function not found".

To understand it, you should know how phars work internally. If you open a phar file in an editor you should find something like this:

#!/usr/bin/env php

<?php

Phar::mapPhar('filename.phar');

$application = require_once 'phar://filename.phar/src/bootstrap.php';
$application->setPharMode(true);
$application->run();

__HALT_COMPILER(); ?>
[binary content follows]

Phar files are executed by PHP just as any other PHP files, the archived source is behind a __HALT_COMPILER() statement. Phar::mapPhar() reads the file itself starting at COMPILER_HALT_OFFSET, i.e. after __HALT_COMPILER().

The error message means, that this __HALT_COMPILER() statement cannot be found and PHP does not know where to start reading the actual phar. Thus "internal corruption of phar". Since the script does at least run and not fail immediately with a parse error, I guess the binary content is missing completely. Open the phar in a text editor to find out.

I actually don't know, why the phar is corrupt, but I can imagine that __HALT_COMPILER somewhere in the source code will be a problem, when the files are combined into one archive.

like image 76
Fabian Schmengler Avatar answered Oct 11 '22 19:10

Fabian Schmengler