zigar_use(path, params = null) ᴾᴴᴾ - chung-leong/zigar GitHub Wiki
JavaScript | PHP
Load a Zig module, referenced by either a source path or a module path.
If path points to a source file, the extension would first recompile the module (unless
recompile is turned off in php.ini). The module path would be derived
by combining the directory containg the source file with
module_rel_path.
Usage:
const std = @import("std");
pub const pi = std.math.pi;
pub const Point = struct {
x: f64,
y: f64,
};
pub var number: i32 = 123;
pub fn hello() void {
return std.debug.print("Hello world\n", .{});
}
<?php
$m = zigar_use(__DIR__ . '/use-example-1.zig');
$point = new $m->Point(x: 123, y: 456);
print_r($point);
$m->hello();
echo $m->pi, "\n";
Point Object
(
[x] => 123
[y] => 456
)
Hello world
3.1415926535898
Arguments:
path- Path to the.zigfile or.zigardirectoryparams- Array containing configuration parameters overriding those set throughphp.ini
Return value:
object