How to install Yii2 on windows xampp

Rakesh Sharma      No Comments  

How to install Yii2 on windows xampp using composer or manually

There are two ways in which you can install yii2 on your windows xampp server using composer tool or manually. Lets take a glance on both the steps. Best way to install yii2 on windows xampp is using composer it’s will be a automatically setup process no need to download packages, composer handle this process automatically just need to give a command.

How to install Yii2 on windows xampp using composer :-

Composer is a popular dependency manager tool for php .The advantage of using the composer is that it automatically downloads and configures any extension with your project with much ease. Its really helpful in project development stage as its saves a lot of time.To install composer on your windows system you need to download the composer setup file. let’s see steps how to install yii2 on windows xampp using composer.

1. Download composer install setup file from here Composer for Windows.
2. Save the downloaded file and run installation (it’s require your php installation path so next step you need to choose php.exe).

C:\xampp\php\ (which drive you have installed php)

3. After successfully install to check whether composer is installed correctly open your command prompt and execute the command



Note :- In case you get any error you might need to configure the environment setting variable for composer. To do so go to your Control Panel >> System >> Advanced System Settings . On the opened dialog window click on Environment Variables. You will get another dialog window opened. Now on the new dialog window edit the “PATH” under “system variables” to point it to the directory containing composer.phar file. In my case it is “C:\ProgramData\ComposerSetup\bin”.

4. Now let us install the composer assets plug-in for composer. Its very useful to manage the project asset files e.g css and javascript without installing the Bower or NPM tools. Just run the following command to install it.

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

Note :- You might be asked to provide your github credentials during this process . Just provide your git hub username and password there.
Now we have installed and configured the composer successfully we will proceed to install yii2.

5. Have a look on the following steps to install Yii2.
a. Move to a web accessible directory. In my case its D:\xampp\htdocs. it’s my location where i want to install yii2. So I will execute the following command in command window.

cd D:\xampp\htdocs

b. Now lets say I want to install Yii2 to a folder named yii2Basic inside htdocs folder. For that I will execute the following command. You may choose whatever name for your project you want to.

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

Note :- you can pass your installation path directly and your yii2 directory name in command on installation like :- “–prefer-dist” will be your preferred location to install yii2 and MY_YII2_DIR_NAME would be your application directory name you want to give.

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


Thats all ! Composer now download all the required repositories and configure them automatically. Your application with Yii2 is now ready. You can access it by http://localhost/yii2Basic/web.

How to install Yii2 on windows xampp manually :-

To install yii2 manually from the archive file just follow the simple steps below.

1. Download the archive file from

2. Unpack the downloaded file to a Web-accessible folder.(D:\xampp\htdocs\yii2Basic in this case) Make sure that the installation directory is writable by the web server.

3. Modify the “config/web.php” inside the installation directory file by entering a secret key for the cookieValidationKey configuration item (this is done automatically if you are installing Yii2 using Composer).

'cookieValidationKey' => 'enter your secret key here',

You can now acces your site by http://localhost/yii2Basic/web. Now you are all set with how to install yii2 on windows xampp using composer and manually install process. Your new site initial look should be like this.

How to install Yii2 on windows xampp