12.4.1 Getting started with Haxe/PHP

To get started with Haxe/PHP, create a new folder and save this class as Main.hx.

import php.Lib;

class Main {
  static function main() {
    Lib.println('Haxe is great!');
  }
}

To compile, either run the following from the command line:

haxe -php bin -main Main

Another possibility is to create and run (double-click) a file called compile.hxml. In this example the hxml file should be in the same directory as the example class.

-php bin
-main Main

The compiler outputs in the given bin-folder, which contains the generated PHP classes that prints the traced message when you run it. The generated PHP-code runs for version 5.1.0 and later.

More information