Yii2 has a new and improved application structure. It uses composer to manage its dependencies. Yii1 has only a basic application structure. While Yii2 has basic as well as advanced application structure.
Yii2 divides the entire application into following sections:
Yii2 Directory Structure
There is one more asset folder inside the web directory. Yii uses this folder to cache the assets. It will have a .gitignore in this folder.
This directory allows you to create Yii management scripts to run. These commands can be executed on command line by going on Yii root directory and typing php yii or ./yii. It will display a by default available commands list .
The config folder includes configuration settings which include e-mail sending, database connection, etc.
Controllers manage data traffic in MVC framework. When request is made, it is controller that processes that request.
It stores templates that Yii uses to construct a mail.
Models manage all the database work in MVC. Any type of coding related to database is written in model.
This folder is used during processing of a web requests.
This folder checks the functionality.
Yii source files reside in this directory. Third party installed module will be stored here. During upgradation, codes in this folder are overwritten hence code alteration in this directory should be avoided.
Views in MVC contains the pages which are displayed upon a web request. All the HTML coding is done in view directory.
This is the document root directory that the web server points to. The index.php file launches the Yii process when called. In this file, debugging code can be turned on or off. Debug bar is viewable at the bottom of the page.
Here you can put any files, images or anything else which needs web accessibility. Files placed in this folder only will be accessed.
Inside this web directory a subdirectory named asset is also present. This directory is used to respond web requests.