PHP Printer Build Status

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.

Roadmap

PHP Printer just started, so there's nothing available yet. Here's the roadmap:

  • [x] 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.

Want to know more?

Here's the documentation:

You can see the current and past versions using one of the following:

And finally some meta documentation: