phpnatives

Files to help writing applications to PHP target.
https://bitbucket.org/yar3333/haxe-phpnatives

To install, run:

haxelib install phpnatives 3.2.0 

See using Haxelib in Haxelib documentation for more information.

README.md

phpnatives

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

The source repo also contain several tools to automatic downloading and convertion from http://php.net/ docs into Haxe classes.

Installation

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>();
ksort(arr);

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:

trace(GlobalVars._FILES);
Contributors
yar3333
Version
3.2.0
Published
2 years ago
License
LGPL

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! try.haxe.org

Join us on Github!

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

Haxe on Github