klitsche/ffigen
CLI tool to generate and update low-level PHP FFI bindings from C headers. Produces constants.php and Methods.php (static method wrappers with phpdoc). Configurable via .ffigen.yml and optional custom parser hooks for preprocessing.
librdkafka, OpenSSL, or proprietary SDKs). Ideal for legacy system modernization or performance-critical paths.Parser classes enable domain-specific adaptations, such as:
register() in a service provider.FROM php:8.2-fpm-alpine with docker-php-ext-install ffi).extension_loaded('ffi')) and graceful degradation (e.g., log warnings or use alternative libraries).composer install or PR checks).artisan command to regenerate bindings.post-install-cmd or post-update-cmd to auto-generate bindings:
scripts:
post-install-cmd: ["vendor/bin/ffigen"]
.ffigen.yml: Create a Laravel-specific template to standardize configurations (e.g., default output paths, namespace conventions)..env) or config files to resolve header/library paths (e.g., HEADER_PATH=/usr/local/include).constants.php in autoload.files and register the Methods trait in autoload-dev.psr-4.$this->app->singleton('ffi.uuid', function () {
return new class {
use \Generated\UUID\Methods;
};
});
^0.8 in composer.json and monitor for updates.malloc in C). Mitigation:
finally blocks or Laravel’s Illuminate\Support\Manager).struct, enum) may not map cleanly to PHP. Mitigation:
Parser to customize type handling (e.g., convert struct to Laravel collections).ext-curl on Windows").bootstrap/cache/ to avoid regeneration.Log facade) for observability.vlucas/phpdotenv, spatie/laravel-activitylog) that already solve the use case?docker-php-ext-install ffi or custom PHP builds.post-install-cmd).ffigen:generate command for manual triggers or CI hooks.FFICallbackExecuted).Snappy for non-production assets).libuuid, then librdkafka).How can I help you explore Laravel packages today?