creating first application in yii2 steps.....

Hi,

here are the steps to create a web app in yii2.0 for those who are new to yii 2.0.

hope it will be helpful.


*Installing Yii :


install Yii with two different ways, using Composer or by downloading an archive file.

(*) Installing from an Archive File :

  1. Download the archive file from www.yiiframework.com.

    Download one of the following archive files, and then extract it to a Web-accessible folder:

     Yii 2 with basic application template
    
    
     Yii 2 with advanced application template
    
  2. Unpack/Extract the downloaded file to your www folder. and then rename it with your application name for example: MyFirstApp

  3. Change the config/web.php file by entering a secret key for the cookieValidationKey configuration item.

    Give proper key in : ‘cookieValidationKey’ => ‘enter your secret key here’,

    like : ‘cookieValidationKey’ => ‘testingapp’,

  4. open browser and type localhost/MyFirstApp/

your application is successfully created.

Upto this you just create simple application.

Now try to configure with you database.

first of all create database : and create some tables in that.Now connect with your application:

  1. return [

    'class' => 'yii\db\Connection',
    
    
    'dsn' => 'mysql:host=localhost;dbname=test123',
    
    
    'username' => 'root',
    
    
    'password' => 'ubuntu',
    
    
    'charset' => 'utf8',
    

    ];

  2. You can then access Gii through the following URL:

    localhost/MyFirstApp/web/index.php?r=gii

Now you can create Model Generator and CRUD Generator.


Model Generator - This generator generates an ActiveRecord class for the specified database table.

CRUD Generator - This generator generates a controller and views that implement CRUD (Create, Read, Update, Delete) operations for the specified data model.

Controller Generator - This generator helps you to quickly generate a new controller class, one or several controller actions and their corresponding views.

Form Generator - This generator generates a view script file that displays a form to collect input for the specified model class.

Module Generator - This generator helps you to generate the skeleton code needed by a Yii module.

Extension Generator - This generator helps you to generate the files needed by a Yii extension.