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 https://getcomposer.org/download/. Composer setup will ask for PHP installation path, in my XAMPP installation it is:D:\xampp\php\php.exe
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:
http://localhost/basic/web
Install Manually
Manuall Installation of Yii involves three steps:- Download the archive file from yiiframework.com.
- Unpack the downloaded file to a Web-accessible folder, in our example it is D:\xampp\htdocs\basic
- Modify the
config/web.php
file by setting a secret key for thecookieValidationKey
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:
http://localhost/basic/web
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.