PHPackages                             daviddeutsch/php-rapidgen - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. daviddeutsch/php-rapidgen

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

daviddeutsch/php-rapidgen
=========================

A fast PHP code generator from concise templates.

113PHP

Since Dec 14Pushed 12y ago3 watchersCompare

[ Source](https://github.com/daviddeutsch/php-rapidgen)[ Packagist](https://packagist.org/packages/daviddeutsch/php-rapidgen)[ RSS](/packages/daviddeutsch-php-rapidgen/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependenciesVersions (1)Used By (0)

PHP-Rapidgen
============

[](#php-rapidgen)

### Why?

[](#why)

[PHP-Parser](https://github.com/nikic/PHP-Parser) is an awesome tool but falls a little flat in the code generation area. The templating is basic and the syntax in general is quite verbose. Not something you'd want to hand-write or maintain. Also, for some cases, you need a stupid but fast fallback.

### How?

[](#how)

PHP-Rapidgen does two things:

1. Mix PHP-Parser and [handlebars.php](https://github.com/XaminProject/handlebars.php), with canonical template traversal, helpers
2. Introduce a Shorthand JSON syntax for PHP Parser

Handlebars is a great way to write a lot of static code that might need just a touch of dynamic replacements. PHP Parser is great for super-accurate generation of code.

PHP-Rapidgen uses PHP-Parser as its native source, while also allowing for handlebars templates. Furthermore, you can mix and match them to your heart's content with the one caveat that calling handlebars templates from within a PHP-Parser template can be quite resource intensive as it has to first convert the template back into a PHP-Parser AST.

In general, it is preferable to work in this hierarchy:

```
output
