Yii 1.1: modulegen

Module generator - models controllers actions CRUD
1 follower

This script have an interesting function that not have present on YIIC:

limit the number of table columns that you want display at the admin page of CRUD, imagine, you have 30 colummns in your table;

YIIC CRUD generate 30 large columns in the horizontal way of course out of lay-out

typing crudm mymod 5 {table_name}
this generate only 5 columns at the admin site and at the list action; (see the documentation)

This tool can help you to generate full working app module based from an existing mysql table (CRUD) and usefulls class under a module dir sctructure like default yiic generator for models controllers and cruds.
this code is a modified version of main shell files
ControllerCommand.php
CrudCommand.php
ModelCommand.php


modified files:
ControllermCommand.php
CrudmCommand.php
ModelmCommand.php

commands: crudm modelm controllerm

Resources

Documentation

Requirements

  • Yii 1.1 or above
  • not tested under 1.0 .????

Installation

  • Extract the release file under framework/cli/commands/shell/

Usage

See the following code example:

first crate a module using the module command:
module nodulename;
after this you can start using the following commands:
commands are: modelm,controllerm,crudm
ex for module called mymod and table called mytable:
 
module mymod
modelm mymod mytable
crudm mymod (number_cols) mytable (crudm mymod 5 mytable )
controllerm mymod oneaction anotheraction etc
 
crudm mymod 5 mytable 
OR
crudm mymod mytable
 
>> modelm help
Usage: modelm <moduleID> <class-name> [table-name] ...
This command generates a model class with the specified class name.
 * ModuleID: your module name directory
 * class-name: required, model class name. It can be specified in
   dot syntax (it defaults to application.models.class-name).
 * table-name: optional, the associated database table name. If not given,
   it is assumed to be the model class name.
 
 
>> controllerm
USAGE
  controllerm <moduleID> <controller-ID> [action-ID] ...
 
DESCRIPTION
  This command generates a controller and views associated with
  the specified actions.
 
PARAMETERS
 * ModuleID: your module name directory
 * controller-ID: required, controller ID (e.g. 'post', 'admin/user')
 * action-ID: optional, action ID. You may supply one or several
   action IDs. A default 'index' action will always be generated.
 
>> crudm
USAGE
  crudm <moduleID> <columns> <model-class> [controller-ID] ...
 
DESCRIPTION
  This command generates a controller and views that accomplish
  CRUD operations for the specified data model.
 
PARAMETERS
* ModuleID: your module name directory
* Columns: Number os columns to show at admin and list actions
 * model-class: required, the name of the data model class. This can
   also be specified using dot syntax (e.g. application.models.Post)
 * controller-ID: optional, the controller ID (e.g. 'post', 'admin.user').
   If absent, the model class name will be used as the ID.

Change Log

v1.2 30 MARCH crudm have option to limit the columns generated from table only for list and admin action, update,edit addnew work normal with full table columns.

March 29, 2009

v1.0* Initial release.

Total 6 comments

#7900 report it
megabr at 2012/04/25 07:48am
use GII (this module is outdate, only for study)

Yii finally add to core all funcions in a web interface called GII. thanks for all people that help improving with ideas for this.

regards

Max

#491 report it
boydzethuong at 2010/05/16 10:36am
not work for me

it generated something like this:

<?php /** * This is the template for generating a controller class file. * The following variables are available in this template: * - $className: the class name of the controller * - $actions: a list of action names for the controller */ ?> <?php echo "<?php\n"; ?>

class <?php echo $className; ?> extends Controller { <?php foreach($actions as $action): ?> public function action<?php echo ucfirst($action); ?>() { $this->render('<?php echo $action; ?>'); }

<?php endforeach; ?> ...

#1797 report it
megabr at 2009/03/31 11:16am
function that not have present on YIIC

this script have an interesting function that not have present on YIIC:

limit the number of table columns that you want display at the admin page of CRUD, imagine, you have 30 colummns in your table;

YIIC CRUD generate 30 large columns in the horizontal way of course out of lay-out

typing crudm mymod 5 inventory this generate only 5 columns at the admin site and at the list action;

#1801 report it
jonah at 2009/03/30 11:52pm
false

http://code.google.com/p/yii/source/detail?r=903

#1802 report it
megabr at 2009/03/30 11:00pm
any aditional info...?

At this date (svn) YIIC only support module command for create a module structure nothing more.. :(

#1803 report it
jonah at 2009/03/30 09:23pm
obsolete

this functionality was finally implanted into the core, making this pretty much obsolete (except for those who don't like using the SVN)

Leave a comment

Please to leave your comment.

Create extension
  • Yii Version: 1.1
  • License: New BSD License
  • Developed by: megabr
  • Category: Console
  • Votes: +2 / -1
  • Downloaded: 968 times
  • Created on: Mar 29, 2009
  • Last updated: Apr 2, 2009