automatically Generate crud code in yii framework

Using Gii

Before we use Gii, the automatic code generator, we need to install it into our code base.

Installing Gii into the application

Run the following command to fetch the required files to use Gii:

$ php composer.phar require --prefer-dist "yiisoft/yii2-gii:*"

The command-line parameter --prefer-dist is used, so we’ll only get the files needed to use Gii, not develop it.

Now we need to wire Gii into our application:

  1. First, as we’re going to use something installed by Composer in our application, we need the autoloader from Composer. It’s located as a file called autoload.php under the vendor subdirectory. The require call should be placed inside the entry point of our application in the web/index.php file:
    <?php
    define('YII_DEBUG', true);
    
    require(__DIR__ ...
    
    

About the author

Deven Rathore

Deven Rathore

I'm Deven Rathore, a multidisciplinary & self-taught designer with 3 years of experience. I'm passionate about technology, music, coffee, traveling and everything visually stimulating. Constantly learning and experiencing new things.

Pin It on Pinterest

Shares