PHP Printer aims at providing a Pretty Printer powered by a templating engine, for PHP Parser.
If you're not familiar with it, PHP Parser is a fantasic library that provides:
- an Abstract Syntax Tree (AST), allowing you to describe PHP code programatically
- a Parser that reads actual PHP code and builds an AST out of it
- a Pretty Printer that can convert the AST back to actual PHP code
Unfortunately, the code generated by its Pretty Printer can only be customized
by extending the PhpParser\PrettyPrinter\Standard
class
(see this PSR-2 example).
Using a template engine, those coding style can be more easily customized: all we'd need is to create a template, and use it to overwrite the default one.
PHP Printer just started, so there's nothing available yet. Here's the roadmap:
- Create a Templating Engine (an interface to allow third party implementations such as Twig, and a simple implementation since one of the drawback of Memio seemed to have been its usage of Twig)
- Create a Pretty Printer (based on the strategy pattern to allow extension points, and a start templates: classes, interfaces, properties and method signatures. See Simpla RFC)
We're going to use our experience with Memio to make PHP Printer the right tool for PHP code generation! At least that's what we aim for.
Here's the documentation:
You can see the current and past versions using one of the following:
- the
git tag
command - the releases page on Github
- the file listing the changes between versions
And finally some meta documentation: