Fatal error: Uncaught Error: Not a Hack file. can HHVM run .php file?

837 views Asked by At

Just installed HHVM and trying to run a simple index.php file, but getting the error below:

"Fatal error: Uncaught Error: Not a Hack file"

Commands that produce the error above:

hhvm index.php
hhvm --php index.php

index content::

<?php
phpinfo();

hhvm version: HipHop VM 4.86.1

Note: I can run a hack file without any issue via command line or via FastCGI.

hhvm fib.hack (run with no problem)

Am I missing a flag or a configuration setting? All the tutorials that I have been able to find online state that hvvm should be able to run php with no issue out of the box.

Any help will be appreciated.

1

There are 1 answers

1
Lucky Brain On

You'll enter into other issues but as a first step try using <?hh instead of <?php because it is not allowed in the latest versions of HHVM. The .php extension is still allowed but not the header of the file:

<?hh
phpinfo();

After that you'll enter into issues like "Uncaught Error: Found top-level code" for which you'll need to wrap the code inside an entry point function by adding the attribute and the function as follows:

<?hh

<<__EntryPoint>>
function main_entry_point(): void {
  phpinfo();
}

After that you'll enter into other issues because of the use of phpinfo() and other PHP functions because the HHVM guys are trying to limit PHP usage for some reason.