ininids / aam-php
AAM PHP bindings
2.5.1
2026-05-03 13:05 UTC
Requires
- php: >=8.0
README
PHP bindings for aam-rs using FFI on top of the stable C API.
What you get
- Parse AAM from strings.
- Forward lookup (
key -> value) and reverse lookup fallback (value -> key). - Simple zero-dependency wrapper class for scripting and prototyping.
Build native library
cargo build --release --features ffi
By default AamDocument reads the library from:
AAM_PHP_LIBenv var, if present.target/release/libaam_rs.soas fallback on Linux.
Basic usage
<?php
require_once 'php/src/AamPhp.php';
$aam = new RustGames\Aam\AamDocument("host = localhost\nport = 8080", '/absolute/path/to/libaam_rs.so');
echo $aam->get('host');
// localhost
More examples
<?php
require_once 'php/src/AamPhp.php';
$aam = new RustGames\Aam\AamDocument("env = production\nrole = api");
// direct lookup
var_dump($aam->get('env')); // "production"
// key/value lookup with fallback
var_dump($aam->find('production')); // ["env" => "production"]
// missing key
var_dump($aam->get('missing')); // null
Tests
AAM_RS_LIB=target/release/libaam_rs.so php php/tests/smoke.php
The smoke script includes multiple assertions for valid parsing, reverse lookup, missing keys, and invalid input errors.