Yii StructureYii2 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 StructureassetsAsset bundles are used to include JavaScript and style sheets. Lot of assessment and caching is done through the assets. 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. If JavaScript or CSS files are need to be updated, all the folders in this directory need to be deleted. They can be deleted any time and can be auto-generated by Yii as cache files. commandsThis 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 . configThe config folder includes configuration settings which include e-mail sending, database connection, etc. controllersControllers 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. modelsModels manage all the database work in MVC. Any type of coding related to database is written in model. runtimeThis folder is used during processing of a web requests. testsThis folder checks the functionality. vendorYii 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. viewsViews in MVC contains the pages which are displayed upon a web request. All the HTML coding is done in view directory. webThis 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. Next TopicYii Entry Scripts |