Joey Rivera’s Blog: Automate Db Model Creation with Zend_CodeGenerator_Php_Class
Every project has class of repetitive tasks. One of such tasks is creating models and integrating them with database tables. In his recent post Joey Riviera shows how to automate this process by using Zend_CodeGenerator_Php_Class.
This is where Zend_CodeGenerator_Php_Class comes in. This component of Zend allows you to create php code on the fly. My theory was, instead of manually creating all these files and typing all the field names (very time consuming with lots of room for error), I could use Zend_CodeGenerator_Php to create all the content of my classes and echo it on the screen so I could copy/paste. Once I had this working, I took it to the next step and included the process of saving that content to files on my project folder. After working on this last night, everything worked like a charm and my classes are easily and quickly created, mapped directly to my database structure, by simply calling one method. No room for error either and I can run this at any time!
Joey’s post should help everyone in automating generation of models or similar cases, saving some development time and increasing stability of software.