Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

SitePoint PHP Blog:
Automatic PHP Code Generation with Memio
May 05, 2015 @ 11:52:07

On the SitePoint PHP blog a new tutorial shows you how to generate code with Memio, a relatively new PHP-based tool that lets you define "models" as structures for the code you need generated.

Ever thought of writing code responsible for generating certain PHP classes, methods, properties automatically? Read on to get the details on when exactly automatic code generation may be helpful and – what’s most important – how to implement it properly using the Memio library.

He starts with a bit of introduction to the basic concept of code generation and mentions a few places it's currently used. Then he gets into the examples, starting with a bit of code showing how to get Twig loaded and injected into the Memio instance. From there he shows a simple example of creating a class with a single method and single line of code. With the basics understood, he gets into a more "real world" example of generating ORM classes with getters and setters for the different properties/column names.

tagged: tutorial generate code memio library example orm realworld

Link: http://www.sitepoint.com/automatic-php-code-generation-memio/