YII 2 – Installation

I have to start a new project in Yii 2 and its a good time to start a new blog series to share our experience with Yii.

Lets start from the installation. I followed the documentation and found out there are number of ways to install Yii from their site. Two of the popular approaches are

  • Download it from GitHub and copy & paste it to the web directory of your localhost server
  • Install it using composer in the web directory of your localhost server

Install Using GitHub

Yii comes in two different templates

I will prefer to start with the basic template. Basic template is easy to manage as well as understandable for the beginners. Once downloaded from the GitHub copy and paste the folder “basic” to the directory of localhost. I am using WAMP so my directory for WAMP is www. Click here to see how to test if everything is working.

Install Using Composer

If you do not have composer already you can download it from getcomposer.org. Since i am using windows i downloaded and executed the installation file for composer. Once installation is done, i started command prompt and executed the following command to check everything is properly installed.



Now that composer is installed, we may need to manage php assets using composer later on. Run the following command in command prompt to get the asset manager via composer.

composer global require "fxp/composer-asset-plugin:^1.2.0"

Now that we have composer and the asset manager we can start getting Yii basic template using composer by running the following command. Its better to navigate to the directory where Yii needs to be placed before getting Yii.

e:/wamp/www> composer create-project --prefer-dist yiisoft/yii2-app-basic basic

Composer will start its job and check all the dependencies needed for the basic template, download them and place everything where it is needed.


It may stop installing and apparently show with a message

Head to https://github.com/settings/tokens/new?scopes=repo&descripiton=composer+on+[pc_name]+[date & time]

It means your system do not have an authentication token from github that can be used to download the projects/codes from github. You need to do following manual steps before the installation can continue.

  • Copy the https URL from your command prompt where it says “Head to …”.
  • Browse the https URL in your browser. If you are not logged in to github it will ask you to login with your credentials.
  • After login you will be navigated to the following page.


Scroll down and  press the button “Generate token”


A new token will be generated for you to access github from composer.


Access tokens are sensitive information i have removed mine from the screen shot. You can copy this token and paste it into the command prompt window and press enter to start installation of Yii.


Everything is perfect

You can go to your browser and browse the local URL to check if everything is working perfect. In my case the URL is http://localhost:83/basic/web/

I have installed Yii in basic folder and it has a child directory web which is the root directory for a Yii project. We will explore it further in up coming posts.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.