PHPackages                             ircmaxell/php-c-parser - 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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. ircmaxell/php-c-parser

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

ircmaxell/php-c-parser
======================

Parse C when using PHP

v0.2.0(1mo ago)4414.6k↑31.3%7[4 issues](https://github.com/ircmaxell/php-c-parser/issues)[1 PRs](https://github.com/ircmaxell/php-c-parser/pulls)2MITPHPPHP &gt;=8.4CI passing

Since Oct 24Pushed 1mo ago3 watchersCompare

[ Source](https://github.com/ircmaxell/php-c-parser)[ Packagist](https://packagist.org/packages/ircmaxell/php-c-parser)[ RSS](/packages/ircmaxell-php-c-parser/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (2)Dependencies (4)Versions (6)Used By (2)

PHPCParser
==========

[](#phpcparser)

This is a library to parse C code into an AST. Using PHP.

Yes, this is an extraordinarily bad idea...

Requirements
------------

[](#requirements)

- PHP 8.4 or later

Example
-------

[](#example)

```
$parser = new PHPCParser\CParser;

$ast = $parser->parse('path/to/file');
```

Note that pre-processor directives are all correctly resolved.

If you need to set a pre-processor define, you can use a context;

```
$parser = new PHPCParser\CParser;

$context = new PHPCParser\Context;
// #define A 42
$context->defineInt('A', 42);
// #define B "testing"
$context->defineString('B', "testing");
// #define C testing
$context->defineIdentifier('C', 'testing');
// etc...

$ast = $parser->parse('path/to/file', $context);
```

And that's all there is to it (until it is working that is...)...

Generating AST from clang
-------------------------

[](#generating-ast-from-clang)

```
$ clang -cc1 -ast-dump test.c
```

###  Health Score

57

—

FairBetter than 98% of packages

Maintenance87

Actively maintained with recent releases

Popularity37

Limited adoption so far

Community22

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor1

Top contributor holds 61.5% 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.

###  Release Activity

Cadence

Every ~1189 days

Total

3

Last Release

57d ago

PHP version history (2 changes)v0.1.0PHP &gt;=7.4

v0.2.0PHP &gt;=8.4

### 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 (75 commits)")[![ircmaxell](https://avatars.githubusercontent.com/u/660654?v=4)](https://github.com/ircmaxell "ircmaxell (36 commits)")[![dirx](https://avatars.githubusercontent.com/u/795259?v=4)](https://github.com/dirx "dirx (7 commits)")[![Fantom409](https://avatars.githubusercontent.com/u/14968877?v=4)](https://github.com/Fantom409 "Fantom409 (1 commits)")[![McCaulay](https://avatars.githubusercontent.com/u/31845045?v=4)](https://github.com/McCaulay "McCaulay (1 commits)")[![sasezaki](https://avatars.githubusercontent.com/u/42755?v=4)](https://github.com/sasezaki "sasezaki (1 commits)")[![tored](https://avatars.githubusercontent.com/u/363750?v=4)](https://github.com/tored "tored (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/ircmaxell-php-c-parser/health.svg)

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

###  Alternatives

[mck89/peast

Peast is PHP library that generates AST for JavaScript code

19037.7M41](/packages/mck89-peast)[karriere/json-decoder

JsonDecoder implementation that allows you to convert your JSON data into PHP class objects

140439.4k12](/packages/karriere-json-decoder)[sauladam/shipment-tracker

Parses tracking information for several carriers, like UPS, USPS, DHL and GLS by simply scraping the data. No need for any kind of API access.

9642.0k](/packages/sauladam-shipment-tracker)[jstewmc/rtf

Read and write Rich Text Format (RTF) documents with PHP

46143.1k6](/packages/jstewmc-rtf)[json-mapper/laravel-package

The JsonMapper package for Laravel

25188.9k3](/packages/json-mapper-laravel-package)[moonshine/layouts-field

Field for repeating groups of fields for MoonShine

107.9k](/packages/moonshine-layouts-field)

PHPackages © 2026

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