Make life easy when working with 7.4's FFI

dev-master 2019-09-03 12:06 UTC

This package is auto-updated.

Last update: 2021-01-03 15:10:34 UTC


This is a wrapper library for PHP 7.4's FFI extension.

You provide it with a shared object, and one or more header files, and it automatically generates the C structures and function signatures for you (just like doing it in C would).

Eventually, this will be more structured to provide a "nicer" interface to use the FFI itself.


Currently there are two modes of operation, an "inline" mode:

$libc = (new FFIMe\FFIMe("/lib/x86_64-linux-gnu/"))


And a code generating mode:

(new FFIMe\FFIMe("/lib/x86_64-linux-gnu/"))
        ->codeGen('full\\classname', 'path/to/file.php');

require 'path/to/file.php';
$libc = new full\classname;

The code generating mode is designed to be used in production, where you'd code generate during a build step and ship with your library.

This should now work for the majority of header files. Looking at some of the code, specifically the compiler, there is quite a bit of hard coding. So I don't expect every file to work out of the box. If you find a header file that doesn't work, just open a bug and we'll take a look.

Check out the examples;