How to Install YII2 on windows :
By using Two ways we can install YII and YII2 on windows
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).
C:\xampp\php\ (which drive you have installed php)
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” ]
composer global require "fxp/composer-asset-plugin:1.0.0"
*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.
composer create-project --prefer-dist yiisoft/yii2-app-basic yii2Basic
*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.
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.
Step 1 : Download the archive file from yiiframework.com.
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).
'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.
Thanks!. If you like this article don’t forget to share and comment.