Generating Models, Controllers, and Views

From FuseWiki

Jump to: navigation, search

Contents

[edit] Introduction

Models, Controllers, and Views can be created manually, or you can make use of the scripts provided with FUSE in order to automatically generate them for you. After running the Scaffold Script, your application directory will contain a subdirectory called manage. In this directory are several useful scripts for use with your FUSE model view controller project:

  • controller.php - generates a controller
  • model_controller.php - generates a model and controller
  • model_view_controller.php - generate a model, a view, and a controller
  • model.php - generates a model
  • view.php - generates a view


[edit] Syntax

[edit] Model/View/Controller

To create a model, controller, default views, and routes (list, edit, view, delete, add), you can use the model_view_controller.php script that are located in the Manage folder inside your just created project.

for one table:

>php manage/model_view_controller.php my_table_name


for all existing tables:

>php manage/model_view_controller.php ALL_TABLES

[edit] Models

to generate a model, the syntax is:

model.php table_name|ALL_TABLES

to generate a Model for your blog_entries table:

>php manage/model.php blog_entries

to automatically generate models for all of your existing tables:

>php manage/model.php ALL_TABLES

[edit] Views

to generate a view, the syntax is:

view.php controller_name action_name

to generate a Model for your ContactController's index action:

>php manage/view.php Contact index

[edit] Controllers

To generate a controller, the synax is:

php controller.php controller_name [parent_class]

To generate a regular application controller (ContactController.class.php) for a contact form:

>php manage/controller.php Contact

To generate a data controller for blog entries:

>php manage/controller.php BlogEntry FuseDataController
Personal tools