Monday, January 9, 2012

How to Use Crud Generator (Gii Tool - Yii Code Generator)

After I have discussed previously the Controller of making post "How to Use Controller Generator (Gii Tool - Yii Code Generator)" and also the model on the post "How to Use Model Generator (Gii Tool - Yii Code Generator)", I would go again in How to Use Crud Generator (Gii Tool - Yii Code Generator). CRUD (Create Read Update Delete) generator generates a controller and views that implement CRUD operations for the specified data model. Please follow these steps below to use this generator:
  1. Open yii code generator - http://localhost/webappname/index.php?r=gii/default/login
  2. Select Crud Generator and enter the name of your model you created in the Model Generator. It should be noted that the use of uppercase and lowercase letters should be tailored to the name of the Model Class we have made to the Model Generator. In the previous example the discussion of Model Generator, Model name is its Class User (letter U in the word using the letters of the user). And select preview and cetang all existing Code File and click generate.

    On Crud Generator you will see the results on protected\views\user\

    generated controllers\UserController.php
    generated views\user\_form.php
    generated views\user\_search.php
    generated views\user\_view.php
    generated views\user\admin.php
    generated views\user\create.php
    generated views\user\index.php
    generated views\user\update.php
    generated views\user\view.php

  3. To view the results please click on try it now or go on http://localhost/webappname/index.php/user
  4. To operate the CRUD (Create-Read-Update-Delete), you must first login. Open http://localhost/webappname/index.php/site/login

  5. Then go again http://localhost/webappname/index.php/user/. You can see there is not a user.
  6. Have you gone to http://localhost/webappname/index.php/user/create. to create a new user - Create User
  7. If you have made, you can see it back in http://localhost/webappname/index.php/user/index - User List
  8. To Manage User (Create-Read-Update-Delete), you can open it in http://localhost/webappname/index.php/user/admin - Manage Users (View, Update, Delete)
Thus means that you have successfully created a web application CRUD (Create-Read-Update-Delete)
Yii Framework Tutorials

Sunday, January 8, 2012

How to Use Controller Generator (Gii Tool - Yii Code Generator)

Once we have made previous models in the example application of Model Generator (Gii Tool - Yii Code Generator), we proceed again on making the controller. Controller Generator helps you to quickly generate a new controller class, one or several controller actions and their corresponding views. The following implementation steps Controller Generator (Gii Tool - Yii Code Generator)
  1. Login to Gii - http://localhost/webappname/index.php?r=gii/default/login 
  2. Then click on the menu Controller Generator - http://localhost/webappanme/index.php/gii/controller
  3. Fill Controller ID with a user (in accordance with the table we have made)

  4. Click preview and then generate.


    Generating code using template "D:\xampp\htdocs\yii\framework\gii\generators\controller\templates\default"... generated controllers\UserController.php generated views\user\index.php done!


  5. Click to try it now or go to this link http://localhost/webappname/index.php/user, and see the results