2015年5月5日星期二

SitePoint PHP Blog: Automatic PHP Code Generation with Memio


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.


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

没有评论:

发表评论