Files to help writing applications to PHP target.

To install, run:

haxelib install phpnatives 3.2.0 

See using Haxelib in Haxelib documentation for more information.


phpnatives is a Haxe wrapper for standard PHP functions/classes/interfaces.

The source repo also contain several tools to automatic downloading and convertion from docs into Haxe classes.


haxelib install phpnatives

Using TypedArray class

To have typed array, use php.TypedArray<K,V> instead of php.NativeArray. TypedArray is just abstract for NativeArray. Examples:

// create new empty php array
var arr = new TypedArray<String, Int>();

// create new TypedArray<Int, String> from Haxe array
var arr = TypedArray.fromArray([ "abc", "def", "xyz" ]);

// create new TypedArray<Int, String> from Haxe map
// note: items order may not be keeped due to Haxe map source!
var arr = TypedArray.fromMap([ 5=>"abc", 10=>"def", 15=>"xyz" ]);

var strArr = new TypedArray<String, String>(); // keys of String
strArr["key"] = "value";

// PHP's foreach analog
arr.foreachKeyValue(function(key, value)
	trace(key + " = " + value);

// iterate values
for (value in arr) trace(value);

// iterate keys
for (key in arr.keys()) trace(key);

Using PHP functions

Just use php.***Natives classes:

import php.ArrayNatives.ksort;
import php.TypedArray;
import php.VarNatives.empty;

// ...

var arr = new TypedArray<String, Int>();

if (empty(arr)) trace("Array is empty.");

Using PHP Classes

Look into php.*** packages:

import php.calendar.DateTime;

// ...

var date = new DateTime();
trace(date.format('d.m.Y H:i:s'));

Using Global Variables

Use php.GlobalVars class:

2 years ago

All libraries are free

Every month, more than thousand developers use haxelib to find, share, and reuse code — and assemble it in powerful new ways. Enjoy Haxe; It is great!

Explore Haxe

Haxe Manual

Haxe Code Cookbook

Haxe API documentation

You can try Haxe in the browser!

Join us on Github!

Haxe is being developed on GitHub. Feel free to contribute or report issues to our projects.

Haxe on Github