Yii 2 Installation Lesson 1

swapnil.tech yii 2

1. How To Install The Yii 2 Basic App..? Remove Web folder From URL

In this section we will learn how to install the Yii 2 basic app in Windows 10 Operating System. And Setup With URL for removing “/web” from the URL. 

A} First Download The Basic Yii Compressed File From The Official Site. The Download Link ( Click 2 Download Yii2 )

B} Extract it in  C:xampphtdocsbasic . Now your Web Directory Should look like this.

C} Now Open The Folder Basic in your favourate Editor..I am using Visual Code. If you need you can download it from here.(Click 2 Download Visual Code Editor) Then Open the file basic/Config/web.php and add some random key as ‘cookieValidationKey’


Now Run The URL http://localhost/basic/web/ in Browser. You should see the screen as below.

Create 2 files in basic directory with following content.


// comment out the following two lines when deployed to production
defined(‘YII_DEBUG’) or define(‘YII_DEBUG’, true);
defined(‘YII_ENV’) or define(‘YII_ENV’, ‘dev’);

require <strong>DIR</strong> . ‘/vendor/autoload.php’;
require <strong>DIR</strong> . ‘/vendor/yiisoft/yii2/Yii.php’;

$config = require <strong>DIR</strong> . ‘/config/web.php’;

(new yii\web\Application($config))-&gt;run();



RewriteEngine on
# If a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Otherwise forward it to index.php
RewriteRule . index.php

Thats All Now browse http://localhost/basic . You will see the same result as you see for http://localhost/basic/web .

Leave a Comment

Your email address will not be published. Required fields are marked *