# nette/php-generator

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/nette-php-generator).**

2,253 stars · 147 forks · PHP · NOASSERTION

## Links

- GitHub: https://github.com/nette/php-generator
- Homepage: https://doc.nette.org/php-generator
- awesome-repositories: https://awesome-repositories.com/repository/nette-php-generator.md

## Topics

`code-generator` `nette` `nette-framework` `php` `php-generator`

## Description

Php-generator is a metaprogramming library for programmatically generating, inspecting, parsing, and manipulating PHP source code using expressive object-oriented structures. It allows developers to construct classes, interfaces, traits, enums, functions, closures, and complete files without writing raw strings. 

The library features automated namespace resolution to manage fully qualified class names and use statements, preventing naming collisions in generated output. It also includes configurable formatting utilities that transform abstract syntax trees into text strings adhering to established style specifications such as standards like PSR-2, PSR-12, and PER, alongside data serialization tools for converting runtime variables into parseable code representations.

## Tags

### Programming Languages & Runtimes

- [PHP Code Generators](https://awesome-repositories.com/f/programming-languages-runtimes/php-code-generators.md) — Builds classes, functions, namespaces, and entire source files programmatically using an object-oriented structure instead of writing raw strings.
- [Namespace Organization](https://awesome-repositories.com/f/programming-languages-runtimes/module-and-package-management/namespace-organization.md) — Organizes classes, functions, and interfaces into structured namespaces with automated alias resolution and use statements. ([source](https://doc.nette.org/en/php-generator))
- [Metaprogramming Toolkits](https://awesome-repositories.com/f/programming-languages-runtimes/php-reflection-libraries/metaprogramming-toolkits.md) — A tool that parses, inspects, and modifies existing PHP source code through reflection and programmatic manipulation interfaces.
- [Qualified Name Resolution](https://awesome-repositories.com/f/programming-languages-runtimes/qualified-name-resolution.md) — Resolves fully qualified class names and use statements automatically to prevent naming collisions in generated output.
- [Runtime Class Modifications](https://awesome-repositories.com/f/programming-languages-runtimes/dynamic-class-creation/runtime-class-modifications.md) — Updates existing class structures by inheriting methods and properties or implementing abstract requirements dynamically. ([source](https://doc.nette.org/php-generator))
- [Source Function Generation](https://awesome-repositories.com/f/programming-languages-runtimes/generated-function-configuration/source-function-generation.md) — Builds global functions, anonymous closures, and short arrow functions with customizable signatures, parameters, return types, and bodies. ([source](https://github.com/nette/php-generator#readme))
- [Expression Escapers](https://awesome-repositories.com/f/programming-languages-runtimes/literal-value-extraction/expression-escapers.md) — Converts arbitrary runtime values and PHP expressions into safe, parseable code representations suitable for injection into generated output.
- [PHP Code Analysis](https://awesome-repositories.com/f/programming-languages-runtimes/php-code-analysis.md) — Parses existing PHP source files and classes into an object model so they can be analyzed, modified, and re-exported.
- [Source File Parsing](https://awesome-repositories.com/f/programming-languages-runtimes/source-file-parsing.md) — Loads and analyzes existing source files, classes, and functions via reflection or parsing to programmatically inspect, modify, or replicate them. ([source](https://doc.nette.org/en/php-generator))

### Part of an Awesome List

- [Code Formatting](https://awesome-repositories.com/f/awesome-lists/devtools/code-formatting.md) — Converts programmatic code structures into valid text strings complying with standard coding style specifications like PSR-2, PSR-12, and PER. ([source](https://github.com/nette/php-generator#readme))

### Development Tools & Productivity

- [Code Printer Formatters](https://awesome-repositories.com/f/development-tools-productivity/formatting-configurations/code-printer-formatters.md) — Transforms abstract syntax trees into formatted text strings adhering strictly to established coding style specifications and custom rules.
- [PHP Code Formatters](https://awesome-repositories.com/f/development-tools-productivity/php-code-formatters.md) — Transforms programmatic structures into clean, standards-compliant PHP code strings matching established style guidelines like PSR-12.
- [Source Code Loaders](https://awesome-repositories.com/f/development-tools-productivity/code-loading-optimizations/runtime-class-loading/source-code-loaders.md) — Inspects existing source files and running classes to load them back into the object model for dynamic modification.
- [File Assemblers](https://awesome-repositories.com/f/development-tools-productivity/php-file-utilities/file-assemblers.md) — Assembles complete PHP files combining classes, functions, namespaces, and strict type declarations into ready-to-output file structures. ([source](https://doc.nette.org/php-generator))

### Software Engineering & Architecture

- [Syntax Trees](https://awesome-repositories.com/f/software-engineering-architecture/object-oriented-models/object-oriented-modeling/syntax-trees.md) — Constructs a syntax tree using expressive object models so developers assemble valid code structures programmatically without writing raw strings.
- [Object-Oriented Structural Organization](https://awesome-repositories.com/f/software-engineering-architecture/object-oriented-structural-organization.md) — Programmatically builds classes, interfaces, traits, enums, and namespaces with configurable members, types, attributes, and visibility modifiers. ([source](https://doc.nette.org/en/php-generator))
- [Language Construct Generators](https://awesome-repositories.com/f/software-engineering-architecture/code-modernization-guides/language-feature-updates/advanced-feature-documentation/language-construct-generators.md) — Constructs modern language features including property hooks, asymmetric visibility, promoted parameters, and variadic arguments. ([source](https://github.com/nette/php-generator#readme))
