How to Install YII2 on windows

How to Install YII2 on windows :

By using Two ways we can install YII and YII2 on windows

1. Composer

2. Manually

I always prefer to install using composer beacause the composer automatically will install all the required plugins and packages. For that just we need to enter required commend on CMD terminal. Lets take a look of YII installation in Both ways.

How to install Yii2 on windows using composer :-

I am using Xampp. 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.

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

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


*Note : In this case If you get an error, Edit your environment varible [ “C:\ProgramData\ComposerSetup\bin” ]

Step 4 : Install Composer assests plugin. Which is used to mange your assests like Css, javascript and images etc. It is very helpful for the project development. Just run the below commend to install assests plugin.


 *Note : In this cause you will ask you to provide github username and password. Just fill it.
Now you have successfully installed composer. Lets see how to instal YII

Step 6 : 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 commant in commant in CMD.

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

 *Note :- you can pass your installation path directly and your yii2 directory name in commant 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.


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.

Step 1 : Download the archive file from

Step 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.

Step 13: 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).

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.


Thanks!. If you like this article don’t forget to share and comment.