Getting Gii to work

Hi, new Yii (and PHP frameworks) user here.

I’ll make a record here of things I had to do to get Gii to generate my model and the CRUD code. It was quite a pain, so hopefully this thread will be of use to others who follow.

Just going by the documentation here produces errors.

  1. Browsing to the Gii generate page produces a 403 error

Solution:

Make changes in main.php as follows.




'gii'=>array(

    'class'=>'system.gii.GiiModule',

    'password'=>'123456',

    'ipFilters'=>array('192.168.1.55'),

),



The password can be anything you like, you will be asked for it later when you browse to the Gii generate page later. The ipFilters need to be the IP address of your client machine, the one you are operating your browser from.

(2) Model Generator produces error saying it can’t write the .php file

Solution:

chmod the ‘models’ directory so that it is writable by everybody.

(3) CRUD Generator produces errors saying it can’t write the .php files

Solution:

chmod the ‘views’ and ‘controllers’ directories so that they are writable by everybody.

(4) After everything is done and works, set the permissions of the ‘models’, ‘views’ and ‘controllers’ directories back to what they had been.