CRUDifier - richjoslin/rivety GitHub Wiki

CRUD = Create Read Update Delete

The CRUDifier is a command-line PHP script that uses the Zend Framework to introspect a database table and then spits out a bunch of files into specific locations based on your custom module. Those files can then be used for easily managing the contents of that database table from within Rivety.

The file lives here: [webroot]/core/default/bin/crudifier.php

To execute the command, make sure PHP is enabled from the command line. On some systems, it is not enabled by default. Here is what executing the command looks like with both arguments present:

 $ php [webroot]/core/default/bin/crudifier.php mymodulename_custom_db_table 1

There are two arguments that can be passed to the script. The first is the database table name, and that is required. The second is a boolean value (usually just 1 or nothing at all) which indicates if the web pages should be generated on the admin side (1) or the frontend side (0 or nothing).

IMPORTANT: The crudifier expects your database table to be named in this specific way:
  • all lowercase
  • module name first with no spaces
  • followed by an underscore
  • followed by whatever you want (but we have these Database Naming Recommendations)
Example: mymodulename_player_inventory_item

The files generated are:

  • One Model File
    • [webroot]/modules/yourmodule/models/YourCustomModel.php
    • Class Structure: Zend_Db_Table : RivetyCore_Db_Table_Abstract : YourCustomModel
  • One Controller File
    • [webroot]/modules/yourmodule/controllers/YourmodelnameController.php
    • Class Structure if Frontend:
      Zend_Controller_Action : RivetyCore_Controller_Action_Abstract : Yourmodule_YourmodelnameController
    • Class Structure if Admin:
      Zend_Controller_Action : RivetyCore_Controller_Action_Abstract : RivetyCore_Controller_Action_Admin : Yourmodule_YourmodelnameadminController
  • Three View Files (Smarty Templates)
    • [webroot]/modules/yourmodule/views/[admin]/tpl_controllers/yourtable[admin?]/index.tpl
    • [webroot]/modules/yourmodule/views/[admin]/tpl_controllers/yourtable[admin?]/edit.tpl
    • [webroot]/modules/yourmodule/views/[admin]/tpl_controllers/yourtable[admin?]/delete.tpl
After the files are generated, you may go ahead and customize that code from there. It's not a good idea to re-run the Crudifier again for the same database table. The crudifier will not be useful for updating your code if you make changes to the database table.
⚠️ **GitHub.com Fallback** ⚠️