project/ ├── src/ │ └── Main.hx │ ├── bin/ │ └── php/ │ └── build.hxml2. Insert the following code into the
src/Main.hx
file:class Main { static function main() { Sys.println("Haxe is great!"); } }3. Add the following build configuration into the
build.hxml
file:-cp src -main Main -php bin/phpThe configuration above specifies that your source code is stored in
src/
, that your main Haxe file is src/Main.hx
, and that you want Haxe to output the PHP source code into bin/php/
.
Install XAMPP with PHP 7+ if you want a user-friendly user interface to manage your local webserver.
Install PHP 7+ if you don't mind running PHP from the console.
Browse the Haxe API website for the core Haxe APIs that you can use in your project.
You can use PHP-specific APIs in addition to the core Haxe APIs.
Browse the haxelib website for community-developed libraries that you can add to your project.
You can install haxelib libraries globally by running haxelib install <library>
.
You can specify that your project uses a haxelib by adding -lib <library>
to your .hxml
file.
1. Build your Haxe project by running haxe build.hxml
in a console in your project directory.
2. Navigate to your webserver's www
or htdocs
directory and create a sub-directory for your project (for example myproject
).
3. Enter that directory path in your build.hxml
file to have Haxe generate PHP files directly into your webserver's directory.
-cp src -main src/Main.hx -php C:/xampp/htdocs/myproject/
4. Start your PHP webserver (if you are using XAMPP, open the control panel and Start the Apache webserver).
5. Navigate to http://localhost/myproject/
and you should see the output of your PHP project in your browser.
1. Build your Haxe project by running haxe build.hxml
in a console in your project directory.
2. Upload the contents of the bin/php
folder to your web host www
or htdocs
folder.
3. Navigate to your domain or webserver's IP address in your browser to see the output of your PHP project.
1. Build your Haxe project by running haxe build.hxml
in a console in your project directory.
3. Open your console and navigate to your Haxe project directory
2. Run this command to execute your program with the PHP runtime:
php bin/php/index.php
If you need help with anything, visit the vibrant Haxe community and simply ask for help with the details of your project. We have a helpful and active community and you should get your answers quickly!