Monday, January 25, 2016

How to Install Yii2 framework on Windows with XAMPP (as PHP development environment)

In this post, I will explain how to install Yii2 framework on Windows, with XAMPP as PHP development environment.
First you have to install XAMPP you can find here: XAMPP Installer
You can install Yii2 framework by two ways:
  • Install Using Composer
  • Install Manually

Install Using Composer

The recommended approach is to install Yii2 framework using composer, because it will automatically install and configures all the required plugins and packages. You can download composer from Composer setup will ask for PHP installation path, in my XAMPP installation it is:

You can verify if composer is correctly installed, by executing the command composer in command prompt. If you get an error message, it means it is not added in the Environment Variables, so you have to add the composer.exe folder path in Environment Variables.

Next step is to install Composer assets plugin by executing the following command from command prompt:

composer global require "fxp/composer-asset-plugin:~1.1.1"

During installation of asset plugin, it will ask you for Github login credentials, because composer need to get API rate-limit to retrieve the dependent pacackges information from Github, you can find more information on this from Composer Documentation

Here we finished installing composer, and now we have to install Yii2. Move to a web-accessible folder, the folder where we usually place all web projects. In my XAMPP installation it is D:\xampp\htdocs
Now go to command prompt, move to the above mentioned web-accessible folder, and execute following command:
composer create-project --prefer-dist yiisoft/yii2-app-basic basic

It will install Yii2 framework to a folder named basic inside the htdocs folder, you can use your own project name in place of basic(last part in the above command). Then composer will download and configure all the required packages, and finally your Yii2 basic application is now ready. You can try access it by localhost path:

Install Manually

Manuall Installation of Yii involves three steps:
  1. Download the archive file from
  2. Unpack the downloaded file to a Web-accessible folder, in our example it is D:\xampp\htdocs\basic
  3. Modify the config/web.php file by setting a secret key for the cookieValidationKey configuration item (this is done automatically if you are installing Yii using Composer):
        'cookieValidationKey' => 'enter your secret key here',

Thats it, you can access this new basic application by following url:

You should see the following "Congratulations!" page in your browser.

If you did not see this page, please check if your PHP installation satisfies Yii's requirements. Just copy /requirements.php to /web/requirements.php and then access it via http://localhost/requirements.php. If you PHP development environment is properly configured, you should see the output similar to this:

You should configure your PHP installation so that it meets the minimum requirements of Yii. Most importantly, you should have PHP 5.4 or above.



  1. I am a regular user of your post, this one also was very interesting and well written. keep sharing the great work Web Developers in Bangalore | Website Developers in Bangalore

  2. I do like Aptana quite a bit for web development, it does a lot of the grunt work for you once you're over the learning curve...For best and cheap manual Seo services, Web designings. Must check Web Design Bangalore