Caution: The documentation you are viewing is
for an older version of Zend Framework.
You can find the documentation of the current version at:
Introduction - Zend_CodeGenerator
In the most typical use case, you will simply instantiate a code generator class and either pass it the appropriate configuration or configure it after instantiation. To generate the code, you will simply echo the object or call its generate() method.
Both of the above samples will render the same result:
Another common use case is to update existing code -- for instance, to add a method to a class. In such a case, you must first inspect the existing code using reflection, and then add your new method. Zend_CodeGenerator makes this trivially simple, by leveraging Zend_Reflection.
As an example, let's say we've saved the above to the file "World.php", and have already included it. We could then do the following:
The resulting class file will now look like this: