PHPackages                             ircmaxell/ffime - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. ircmaxell/ffime

ActiveLibrary

ircmaxell/ffime
===============

Make life easy when working with FFI

1415.9k↓100%6[1 PRs](https://github.com/ircmaxell/FFIMe/pulls)1PHPCI passing

Since Mar 22Pushed 3mo ago9 watchersCompare

[ Source](https://github.com/ircmaxell/FFIMe)[ Packagist](https://packagist.org/packages/ircmaxell/ffime)[ RSS](/packages/ircmaxell-ffime/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (3)Used By (1)

FFIMe
=====

[](#ffime)

This is a wrapper library for PHP'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). It then provides wrapper classes for all C structures and functions to provide a fully typed experience.

Usage:
------

[](#usage)

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

```
$libc = (new FFIMe\FFIMe(FFIMe\FFIMe::LIBC))
        ->include("stdio.h")
        ->build();

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

And a code generating mode:

```
(new FFIMe\FFIMe(FFIMe\FFIMe::LIBC))
        ->include("stdio.h")
        ->include("other.h")
        ->codeGen('full\\classname', 'path/to/file.php');

require 'path/to/file.php';
$libc = full\classname::ffi();
$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 a bit of hard coding necessary. 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](examples/);

Slimming it down
----------------

[](#slimming-it-down)

Generating FFI for large projects may result in codefiles counting tens or hundreds of thousands of lines, though only a few hundred or thousand are actually needed. This may result in a non-trivial overhead, which can be removed after development.

```
$ffi = (new FFIMe\FFIMe(FFIMe\FFIMe::LIBC))
        ->include("stdio.h");

$ffi->codeGenWithInstrumentation('full\\classname', 'path/to/file.php');

// Run some code providing 100% coverage of all code using FFI
(new PHPUnit\TextUI\Command)->run([$argv[0], "test"], false);

$ffi->codeGen('full\\classname', 'path/to/file.php');
```

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance54

Moderate activity, may be stable

Popularity37

Limited adoption so far

Community21

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 57% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/c87a667fe5a109ed083ba784409a76f0a18f30b0a05445fbb8ef5e4520b7a6e1?d=identicon)[ircmaxell](/maintainers/ircmaxell)

---

Top Contributors

[![bwoebi](https://avatars.githubusercontent.com/u/3154871?v=4)](https://github.com/bwoebi "bwoebi (49 commits)")[![ircmaxell](https://avatars.githubusercontent.com/u/660654?v=4)](https://github.com/ircmaxell "ircmaxell (31 commits)")[![nilslice](https://avatars.githubusercontent.com/u/7517515?v=4)](https://github.com/nilslice "nilslice (2 commits)")[![siad007](https://avatars.githubusercontent.com/u/2149445?v=4)](https://github.com/siad007 "siad007 (2 commits)")[![iggyvolz](https://avatars.githubusercontent.com/u/2197376?v=4)](https://github.com/iggyvolz "iggyvolz (1 commits)")[![mikeytag](https://avatars.githubusercontent.com/u/219403?v=4)](https://github.com/mikeytag "mikeytag (1 commits)")

### Embed Badge

![Health badge](/badges/ircmaxell-ffime/health.svg)

```
[![Health](https://phpackages.com/badges/ircmaxell-ffime/health.svg)](https://phpackages.com/packages/ircmaxell-ffime)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
