Menus

Sunday 6 March 2016

Installing Yii





Yii 2

The latest version of Yii 2 is 2.0.7, released on February 14, 2016. Yii 2.0 is a complete rewrite of Yii on top of PHP 5.4.0. It is aimed to become a state-of-the-art of the new generation of PHP framework. Yii 2.0 is not compatible with 1.1.
Yii2 Website.
Yii2 Documentation.

Installing Yii

  1. Installing via Composer
  2. Installing from an Archive File
  3. Other Installation Options
  4. Verifying the Installation
  5. Configuring Web Servers

You can install Yii in two ways, using the Composer package manager or by downloading an archive file. The former is the preferred way, as it allows you to install new extensions or update Yii by simply running a single command.


Steps - Install from an Archive File
  • Yii 2 with advanced application template       (Download one of the following archive files, and then extract it to a Web-accessible folder (eg /var/www/html).)
  • Yii Application Initialization.     eg var/www/html/yii2.7# php init
Open your browser goto  http://localhost/yii2.7/frontend/web/index.php
Get result is


Database Configuration
  1. Preparing the Database
  2. Configuring a DB Connection
  3. Creating an Active Record
  4. Creating an Action
  5. Creating a View

* Database configuration placed in the common/config directory of application folder.
/application/common/config/main_local.php

Example of set database configuration 
'db' => [
            'class' => 'yii\db\Connection',
            'dsn' => 'mysql:host=localhost;dbname=students',
            'username' => 'root',
            'password' => 'root123',
            'charset' => 'utf8',
        ],

More Details

Migrate Database
yii basic working tables add to own database
This will create tables needed for the application to work.

Command for migration
php yii migrate

Video Installing the Advance Template in Yii



GETTING STARTED
After you install the application, you have to conduct the following steps to initialize
the installed application. You only need to do these once for all.
1. Run command `init` to initialize the application with a specific environment.
2. Create a new database and adjust the `components['db']` configuration in `common/config/main-local.php` accordingly.
3. Apply migrations with console command `yii migrate`. This will create tables needed for the application to work.
4. Set document roots of your Web server:
- for frontend `/path/to/yii-application/frontend/web/` and using the URL `http://frontend/`
- for backend `/path/to/yii-application/backend/web/` and using the URL `http://backend/`
To login into the application, you need to first sign up, with any of your email address, username and password.Then, you can login into the application with same email address and password at any time.


No comments:

Post a Comment