Yii2 installation digest

this is based on and the Yii forum site…

Let’s start by installing Composer for Windows. Download the installer and run it. Installer will ask you to locate php.exe. If you are using xampp, browse to :



and select the purple php file, that is php.exe. If you are using wamp, browse to :



and select purple php file. Note that in my wamp, I have php version “5.5.12”, yours may be different, so just select the folder of your version instead.


1. Go to…gs/applications
2. Create a new token.
3. Run this in cmd:

composer config -g your_oauthtoken_here



Let’s use Composer to install Composer asset plugin. “The Composer Asset Plugin allows you to manage project assets (css, js, etc.) in your composer.json without installing NPM or Bower.” Copy -> paste the following command to your CMD, and execute it.

composer global require "fxp/composer-asset-plugin:1.0.0-beta4"

During installation of this package, you may be asked to enter your GitHub username and password. If you do not have it, just create account there, it is free.

cd c:\xampp\htdocs


for basic use:

composer create-project --prefer-dist yiisoft/yii2-app-basic

and for advanced use this:

composer create-project --prefer-dist yiisoft/yii2-app-advanced


After download is complete we will have to initialize our application, create database and run yii migration to populate that database with boilerplate tables.

To initialize your application, first move inside the yii2-app-advanced folder. In your command prompt execute this command:


cd yii2-app-advanced

Now run the php init file with this command:


php init


You will be asked to chose environment. Chose Development ( type “0” and press enter ) and then you will have to confirm your choice by typing “yes” and press enter again.

Now create database that you will use for this application. You can use any tool you like, for example “phpMyAdmin”. Give it any name you want. Now we have to tell Yii to use this database. In your IDE or text editor open up the “main-local.php” configuration file. Path to this file is:




Inside this file you can set up your database credentials. Write your database name, username and password and save the file.

Inside your command prompt move to yii2-app-advanced folder again and execute this command:


yii migrate


Confirm migration by typing “yes” and press enter.

Now you are ready to start your application and see what you got. Advanced template is consisting from front-end and back-end sides. To start each of them, you can use these URLs:








Congratulations, now you can start developing some cool apps using yii2.


Leave a Reply

Your email address will not be published. Required fields are marked *