Back to Blog

Installing Yii2.0

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

Step 1

Install via Composer(one time only)

The installer will download composer for you and set up your PATH environment variable so you can simply call composer from any directory.

Download and run Composer-Setup.exe – it will install the latest composer version whenever it is executed.

and run following command

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


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

Now choose one of the application templates to start installing Yii 2.0. An application template is a package that contains a skeleton Web application written in Yii.

To install the basic application template, run the command below in the www folder of wamp server:

composer create-project yiisoft/yii2-app-basic yii2basic


php composer create-project yiisoft/yii2-app-basic yii2basic

Above commands will take 10-15 min for installation. please wait….

To install the advanced application template, run the command below:

composer create-project yiisoft/yii2-app-advanced advancedyii2


php composer create-project yiisoft/yii2-app-advanced advancedyii2

Above commands will take 10-15 min for installation. please wait….

Install from an Archive File

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

  • Yii 2 with basic application template
  • Yii 2 with advanced application template

    important Installing from an Archive File

    Installing Yii from an archive file involves three steps:

    1. Download the archive file from
    2. Unpack the downloaded file to a Web-accessible folder.
    3. Modify the config/web.php file by entering a secret key for the cookieValidationKey configuration item (this is done automatically if you are installing Yii using Composer):
      // !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
      'cookieValidationKey' => 'enter your secret key here',


      Verifying the Installation

      After installation is done, either configure your web server (see next section) or use the built-in PHP web server by running the following console command from  the project  directory:

      php yii serve

      Note: By default the HTTP-server will listen to port 8080. However if that port is already in use or you wish to serve multiple applications this way, you might want to specify what port to use. Just add the –port argument:

      //if you want to change the default port otherwise leave it
      php yii serve --port=<portnumber>
      php yii serve --port=8080

      You can use your browser to access the installed Yii application with the following URL:



Share this post

Leave a Reply

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

Back to Blog