ffi/ide-helper-generator

FFI API generator for PHP

Maintainers

Package info

github.com/php-ffi/ide-helper-generator

Documentation

pkg:composer/ffi/ide-helper-generator

Statistics

Installs: 7 848

Dependents: 4

Suggesters: 0

Stars: 6

Open Issues: 1

0.1.12 2024-05-06 20:43 UTC

This package is auto-updated.

Last update: 2026-03-04 00:40:17 UTC


README

PHP 8.1+ Latest Stable Version Latest Unstable Version Total Downloads License MIT

Requirements

Installation

Library is available as Сomposer repository and can be installed using the following command in the root of your project as a dev-dependency.

$ composer require ffi/ide-helper-generator --dev

Usage

Generate Metadata

Before generating the helper, the headers must be parsed to build the metadata data. To do this, castxml will be used, which in turn uses the original compiler (like clang) to build the AST.

use FFI\Generator\Printer\PhpStormMetadataPrinter;
use FFI\Generator\CodeGenerator;

echo new CodeGenerator()
    ->parse(__DIR__ . '/example-header.h')
    ->generate(new PhpStormMetadataPrinter())
    ->save(__DIR__ . '/resources/.phpstorm.meta.php');

Analyze Metadata

After the metadata is generated, it should be parsed and an abstract syntax tree built in memory.

use FFI\Generator\CodeGenerator;

$result = new CodeGenerator()
    ->parse(__DIR__ . '/example-header.h');

foreach ($result->nodes as $namespace) {
    var_dump($namespace);
}