PHPackages                             hiqdev/code-generator-utils - 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. hiqdev/code-generator-utils

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

hiqdev/code-generator-utils
===========================

A set of code generator utilities built on top of PHP-Parsers that ease its use when combined with Reflection

1.8.0(1y ago)01181MITPHPPHP ~8.2.0 || ~8.3.0 || ~8.4.0

Since Jul 27Pushed 7mo agoCompare

[ Source](https://github.com/hiqdev/CodeGenerationUtils)[ Packagist](https://packagist.org/packages/hiqdev/code-generator-utils)[ Docs](https://github.com/Ocramius/CodeGenerationUtils)[ GitHub Sponsors](https://github.com/Ocramius)[ RSS](/packages/hiqdev-code-generator-utils/feed)WikiDiscussions 1.9.x Synced 1mo ago

READMEChangelogDependencies (6)Versions (29)Used By (0)

Code Generation Utils for PHP-Parser
====================================

[](#code-generation-utils-for-php-parser)

Code Generation Utils is a small library that is not yet intended for general use.

It is a small project that aims at collecting common solutions to code generation problems that I often face, and for now it doesn't have a really solid structure.

I built it to workaround limitations that I often faced while working with [`Zend\Code`](https://github.com/zendframework/zend-code), and it is mainly based on the logic of [PHP-Parser](https://github.com/nikic/PHP-Parser).

It will be stabilized together with [GeneratedHydrator](https://github.com/Ocramius/GeneratedHydrator)and [ProxyManager](https://github.com/Ocramius/ProxyManager) when these two both have reached at least version `1.0.0`.

ReleasesDownloads[![Latest Stable Version](https://camo.githubusercontent.com/b4fe0edb3519b65a50f95155a51076b5f01c9b7f0b104f9b472a623d9a408bee/68747470733a2f2f706f7365722e707567782e6f72672f6f6372616d6975732f636f64652d67656e657261746f722d7574696c732f762f737461626c652e706e67)](https://packagist.org/packages/ocramius/code-generator-utils) [![Latest Unstable Version](https://camo.githubusercontent.com/9cfc00ed214e904334e523be2fae36554b0ffe78aaa8c2c6b6d7d73e4ae36c7d/68747470733a2f2f706f7365722e707567782e6f72672f6f6372616d6975732f636f64652d67656e657261746f722d7574696c732f762f756e737461626c652e706e67)](https://packagist.org/packages/ocramius/code-generator-utils)[![Total Downloads](https://camo.githubusercontent.com/e78d6790bd2cdc9ef4043191e025af59cbf5fb6bb44c824b7ac556dc25f075b3/68747470733a2f2f706f7365722e707567782e6f72672f6f6372616d6975732f636f64652d67656e657261746f722d7574696c732f646f776e6c6f6164732e706e67)](https://packagist.org/packages/ocramius/code-generator-utils)Installation
------------

[](#installation)

Supported installation method is via composer:

```
php composer.phar require ocramius/code-generator-utils
```

Provided components
-------------------

[](#provided-components)

The provided components are generally related with code generation and related problems.

### `CodeGenerationUtils\Autoloader`

[](#codegenerationutilsautoloader)

This is a small callback-based autoloader component - it should be used when trying to autoload generated classes.

### `CodeGenerationUtils\FileLocator`

[](#codegenerationutilsfilelocator)

The FileLocator basically represents a map of generated class names to files where those classes should be read from or written to. This component can be useful for non-PSR-0-compliant generated code.

### `CodeGenerationUtils\GeneratorStrategy`

[](#codegenerationutilsgeneratorstrategy)

Provides logic to serialize a PHP-Parser AST to a class. Current strategies allow to:

- Serialize an AST to a string
- Serialize an AST to a string and evaluate it (via `eval()`) at runtime
- Serialize an AST to a string and save it to a file (via `CodeGenerationUtils\FileLocator`)

### `CodeGenerationUtils\Inflector`

[](#codegenerationutilsinflector)

Provides various utilities to:

- Convert a generated code's [FQCN](http://php.net/manual/en/language.namespaces.rules.php)to the FQCN of the class from which it was generated
- Generate the FQCN of a generated class given an original class name and some arbitrary parameters to be encoded (allows multiple generated classes per origin class)
- Generate unique valid identifier names

### `CodeGenerationUtils\ReflectionBuilder`

[](#codegenerationutilsreflectionbuilder)

Very rudimentary converter that builds PHP-Parser AST nodes from Reflection objects (still WIP)

### `CodeGenerationUtils\Visitor`

[](#codegenerationutilsvisitor)

Various visitors used to manipulate classes, methods and properties in a given PHP-Parser AST

Contributing
------------

[](#contributing)

Please read the [CONTRIBUTING.md](https://github.com/Ocramius/CodeGenerationUtils/blob/master/CONTRIBUTING.md) contents if you wish to help out!

###  Health Score

48

—

FairBetter than 95% of packages

Maintenance54

Moderate activity, may be stable

Popularity14

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity91

Battle-tested with a long release history

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~185 days

Recently: every ~158 days

Total

25

Last Release

229d ago

Major Versions

0.4.1 → 1.0.02018-10-15

PHP version history (10 changes)0.1.0PHP &gt;=5.3.3

0.4.0PHP ~7.0

1.0.0PHP ^7.1

1.1.0PHP ^7.4 || ^8.0

1.2.0PHP ^8.0

1.3.0PHP ~8.0.0 || ~8.1.0

1.6.0PHP ~8.1.0 || ~8.2.0

1.7.0PHP ~8.1.0 || ~8.2.0 || ~8.3.0

1.8.0PHP ~8.2.0 || ~8.3.0 || ~8.4.0

1.9.x-devPHP ^8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/790fd24da129907d373559f60c6994f664f06e3f518502c03580cc9f3594615e?d=identicon)[hiqdev](/maintainers/hiqdev)

---

Top Contributors

[![Ocramius](https://avatars.githubusercontent.com/u/154256?v=4)](https://github.com/Ocramius "Ocramius (422 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (306 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (298 commits)")[![dependabot-preview[bot]](https://avatars.githubusercontent.com/in/2141?v=4)](https://github.com/dependabot-preview[bot] "dependabot-preview[bot] (104 commits)")[![renovate[bot]](https://avatars.githubusercontent.com/in/2740?v=4)](https://github.com/renovate[bot] "renovate[bot] (51 commits)")[![gsdevme](https://avatars.githubusercontent.com/u/319498?v=4)](https://github.com/gsdevme "gsdevme (8 commits)")[![zlodes](https://avatars.githubusercontent.com/u/1114387?v=4)](https://github.com/zlodes "zlodes (5 commits)")[![VadymHrechukha](https://avatars.githubusercontent.com/u/114911409?v=4)](https://github.com/VadymHrechukha "VadymHrechukha (5 commits)")[![remicollet](https://avatars.githubusercontent.com/u/270445?v=4)](https://github.com/remicollet "remicollet (2 commits)")[![icarus94](https://avatars.githubusercontent.com/u/11488493?v=4)](https://github.com/icarus94 "icarus94 (2 commits)")[![Majkl578](https://avatars.githubusercontent.com/u/144181?v=4)](https://github.com/Majkl578 "Majkl578 (2 commits)")[![jdreesen](https://avatars.githubusercontent.com/u/424602?v=4)](https://github.com/jdreesen "jdreesen (2 commits)")[![duncan3dc](https://avatars.githubusercontent.com/u/546811?v=4)](https://github.com/duncan3dc "duncan3dc (1 commits)")[![kefzce](https://avatars.githubusercontent.com/u/8298339?v=4)](https://github.com/kefzce "kefzce (1 commits)")[![siwinski](https://avatars.githubusercontent.com/u/1034024?v=4)](https://github.com/siwinski "siwinski (1 commits)")[![staabm](https://avatars.githubusercontent.com/u/120441?v=4)](https://github.com/staabm "staabm (1 commits)")[![tacman](https://avatars.githubusercontent.com/u/619585?v=4)](https://github.com/tacman "tacman (1 commits)")[![tamcap](https://avatars.githubusercontent.com/u/5289937?v=4)](https://github.com/tamcap "tamcap (1 commits)")[![carusogabriel](https://avatars.githubusercontent.com/u/16328050?v=4)](https://github.com/carusogabriel "carusogabriel (1 commits)")[![WyriHaximus](https://avatars.githubusercontent.com/u/147145?v=4)](https://github.com/WyriHaximus "WyriHaximus (1 commits)")

---

Tags

parserreflectioncompilercode-generationphp code

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Type Coverage Yes

### Embed Badge

![Health badge](/badges/hiqdev-code-generator-utils/health.svg)

```
[![Health](https://phpackages.com/badges/hiqdev-code-generator-utils/health.svg)](https://phpackages.com/packages/hiqdev-code-generator-utils)
```

###  Alternatives

[corveda/php-sandbox

A PHP library that can be used to run PHP code in a sandboxed environment

23483.5k2](/packages/corveda-php-sandbox)[composer-unused/symbol-parser

Toolkit to parse symbols from a composer package

145.7M2](/packages/composer-unused-symbol-parser)[mishal/iless

Less.js port to PHP

4737.0k3](/packages/mishal-iless)[ffi/preprocessor

Simple C Preprocessor

2637.0k13](/packages/ffi-preprocessor)[atanamo/php-codeshift

A PHP code transformation toolkit based on 'PHP-Parser'

32158.4k1](/packages/atanamo-php-codeshift)[smuuf/php-peg

PEG parser generator for PHP.

12118.4k3](/packages/smuuf-php-peg)

PHPackages © 2026

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