Getting started with Yii 2

Yii 2 for beginners

Yii 2 comes with two templates, basic and advanced. We will be working with advanced throughout the series.

In order to download the Yii 2 advanced framework, visit http://www.yiiframework.com/download/ and click on the 'Yii 2 with advanced application template'.

 

Once you download the tar file, extract it and move the entire advanced directory to your document root.

You can configure the document root directory in your Apache virtual host configuration file. It is the directory from where your files are served to the browser. Typically located at /var/www/html in Ubuntu environment. In Windows, it is where your WAMP or XAMPP is installed inside the htdocs directory.

So the directory structure looks like below

The root directory contains the following subdirectories:

  • backend - backend web application.
  • common - files common to all applications.
  • console - console application.
  • environments - environment configs.
  • frontend - frontend web application.


Root directory contains a set of files.

  • .gitignore contains a list of directories ignored by git version system. If you need something never get to your source code repository, add it there.
  • composer.json - Composer config described in Configuring Composer.
  • init - initialization script described in Configuration and environments.
  • init.bat - same for Windows.
  • LICENSE.md - license info. Put your project license there. Especially when opensourcing.
  • README.md - basic info about installing template. Consider replacing it with information about your project and its installation.
  • requirements.php - Yii requirements checker.
  • yii - console application bootstrap.
  • yii.bat - same for Windows.

Yii 2 Advanced Directory Structure