Tuesday, November 22, 2011

yii gii

1. First, modify main.php in protected/config
    Uncomment the gii part

1-1. urlManager
    Uncomment the urlManager part in main.php
    That will enable the url to be user-friendly as shown below

2. Browse to gii
    http://localhost/yii/index.php/gii


3. Select Model Generator
    And enter a table name (like Employee), and preview and generate it
    Do the work for as many DB Tables as there should be
    New files will be created in protected/models
    (like protected/models/Employee.php, protected/models/Department.php)


4. CRUD Generator
   (CRUD stands for Create, Retrieve, Update, Delete)

    Do the same for Employee and Department as in the Model Generator
    New controllers will be created in protected/controllers
    (like protected/controllers/EmployeeController.php, protected/controllers/DepartmentController.php)
    And new view directories will be created in protected/views
    (like protected/views/employee/, protected/views/department)



5. See how the webapp changed
    Log out of the gii, and select webap in the menu on the top
    Web-browse to http://localhost/yii/index.php/employee
    Nothing can be done without using password (default is admin/admin)









No comments:

Post a Comment