PHPackages                             event-engine/php-code-generator-event-engine-ast - 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. event-engine/php-code-generator-event-engine-ast

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

event-engine/php-code-generator-event-engine-ast
================================================

PHP Code Generator for Event Engine based on PHP AST

0.1.0(4y ago)5207MITPHPPHP ^7.4 || ^8.0

Since Jan 29Pushed 3y ago2 watchersCompare

[ Source](https://github.com/event-engine/php-code-generator-event-engine-ast)[ Packagist](https://packagist.org/packages/event-engine/php-code-generator-event-engine-ast)[ RSS](/packages/event-engine-php-code-generator-event-engine-ast/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (14)Versions (3)Used By (0)

Event Engine - PHP Code Generator via PHP AST
=============================================

[](#event-engine---php-code-generator-via-php-ast)

PHP Code Generator based on PHP Abstract Syntax Tree. It provides a comprehensive high level API to generate PHP code from [prooph board](https://prooph-board.com/ "prooph board") for [Event Engine](https://event-engine.github.io/ "Event Engine").

It supports the following code generation:

- Event Engine API description for commands, aggregates and domain events
- Command, aggregate and domain event classes with corresponding value objects based on metadata (JSON schema)
- Glue code between command, corresponding aggregate and corresponding domain events

Installation
------------

[](#installation)

Run the following to install this library:

```
$ composer require event-engine/php-code-generator-event-engine-ast
```

If you want to use `Config\PreConfiguredNaming` please install also `laminas/laminas-filter`.

```
$ composer require laminas/laminas-filter
```

Usage
-----

[](#usage)

The code generation is based on the [InspectIO Graph](https://github.com/event-engine/php-inspectio-graph "InspectIO Graph"). There are two implementations of *InspectIO Graph*. The first one is based on the [InspectIO GraphML graph format](https://github.com/event-engine/php-inspectio-graph-ml "InspectIO Graph GraphML")and the second is based on the [InspectIO Cody graph format](https://github.com/event-engine/php-inspectio-graph-cody "InspectIO Graph Cody").

> It is recommended to use the [InspectIO Cody graph format](https://github.com/event-engine/php-inspectio-graph-cody "InspectIO Graph Cody")because it's based on a simple JSON structure.

For out-of-the-box usage you can use the preconfigured configuration file `Config\PreConfiguredNaming`. You are free to change the configuration for your needs. The following example uses the preconfigured configurations.

> Feel free to modify the generated PHP code, because your changes will *NOT* be overwritten (can be overwritten if you want)!

### Code Generation

[](#code-generation)

The following quick example shows how to generate PHP code for *Command* classes with the preconfigured configuration.

- Please see command unit tests (`tests/CommantTest.php`) for comprehensive examples which code will be generated.
- Please see event unit tests (`tests/EventTest.php`) for comprehensive examples which code will be generated.
- Please see aggregate unit tests (`tests/AggregateTest.php`) for comprehensive examples which code will be generated.
- Please see query unit tests (`tests/QueryTest.php`) for comprehensive examples which code will be generated.
- Please see value object unit tests (`tests/ValueObjectTest.php`) for comprehensive examples which code will be generated.

```
