Preprocess and parse C headers, inspect native binaries and locate them on disk — in plain PHP.
Documentation · Packagist · Repositories
A set of independent Composer packages around PHP's FFI extension. They cover the whole path from a C header and a shared library to working FFI bindings: the header is preprocessed and parsed into an AST, and the library is found on disk and its exported symbols are read — without a C compiler or any native tooling. All packages are written in pure PHP and work on Linux, macOS and Windows.
-
ffi/preprocessor — C23 preprocessor: macros, conditional directives,
#include. The output is what the parser is meant to consume. -
ffi/c-parser — C23 (ISO/IEC 9899:2024) header parser that produces an AST.
-
ffi/reflection-library — reads ELF, PE/COFF and Mach-O binaries: exported and imported symbols.
-
ffi/location — resolves the physical path of a binary in the operating system.
-
ffi/env — status and availability of the FFI extension in the current environment.
Every package is installed separately with Composer:
composer require ffi/c-parserBug reports and pull requests are welcome in the repository of the package
they relate to. Please run its test suite (composer test:unit) and code
style check (composer phpcs:check) before opening a pull request.
All packages are open-source software released under the MIT License.