Skip to content
/ FFIMe Public
forked from ircmaxell/FFIMe

A FFI Wrapper library and header parser!

License

Notifications You must be signed in to change notification settings

dirx/FFIMe

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FFIMe

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.

Usage:

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

$libc = (new FFIMe\FFIMe("/lib/x86_64-linux-gnu/libc.so.6"))
        ->include("stdio.h")
        ->build();

$libc->printf("test\n");

And a code generating mode:

(new FFIMe\FFIMe("/lib/x86_64-linux-gnu/libc.so.6"))
        ->include("stdio.h")
        ->include("other.h")
        ->godeGen('full\\classname', 'path/to/file.php');

require 'path/to/file.php';
$libc = new full\classname;
$libc->printf("test\n");

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;

About

A FFI Wrapper library and header parser!

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 99.6%
  • Other 0.4%