Skip to content

daviddeutsch/php-rapidgen

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 

Repository files navigation

PHP-Rapidgen

Why?

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, fast fallback.

How?

PHP-Rapidgen does two things:

  1. Mix PHP-Parser and 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.

This is made possible by a canonical template traversal on the one hand (see below for examples). On the other hand, helpers are natively written in PHP-Parser Syntax (well, a shorthand version) and can also be used from both sources.

Finally, PHP-Rapidgen also handles context canonically such that both handlebars and PHP-Parser derive data from the same source.

Your Project ´´´ project |-- templates | |-- main.handlebars | |-- main.json | +-- simple.php |-- context.json +-- generate.php ´´´

As an example, both the handlebars and the json file produce the same output.

main.handlebars ´´´handlebars

About

A fast PHP code generator from concise templates.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages