Search code examples
phpzend-frameworkcommand-linezend-tool

Generating data objects in Zend Framework


Is there any way to create data objects for MySQL database tables using Zend_Tool?

What I am trying to achieve is to create setter/getter methods and column variable of any table in some class by using command line zf utility. (like we can do it in pear)


Solution

  • You would need to create your own providers for Zend_Tool.

    Essentially, you create a class that extends Zend_Tool_Project_Provider_Abstract. Every public method becomes an action available within the zf.sh tool.

    You also need to register your new provider with Zend_Tool. Do this by running:

    1. run zf --setup storage-directory
    2. run zf --setup config-file
    3. edit ~/.zf.ini and add php.include_path and basicloader.classes.0 entries that point to your new provider's path and classname respectively.

    Further details: http://akrabat.com/zend-framework/akrabat_db_schema_manager-zend-framework-database-migrations/ & https://github.com/akrabat/Akrabat/blob/master/zf1/Akrabat/Tool/DatabaseSchemaProvider.php