Yii Framework Tutorial for Beginners
What is Yii?
The Yii is a light-weighted, open-source PHP based framework which develops web application faster. It is used to accelerate web development applications quickly. It is a component-based, high-performance PHP framework for building large scale applications. This framework is built around the Model-View-Controller composite pattern. It includes an in-built code generator called Gii, which writes the code for you and save your time. The Yii is a Chinese name which means Yes it is. It is proper for every sized project giving a highly optimized performance. Yii Framework has its benefits, and this is the reason for which it is placed at the top spot among the other similar frameworks. Yii even represents the next generation of the PHP frameworks. Moreover, Yii is a supportive wide range of wizards that are used for conducting common tasks such as CRUDing (Creating, Reading, Updating and Deleting). This is not something that we find in any other PHP frameworks.History of Yii
QiangXue initiated the Yij framework on January 1, 2008. This framework was developed to handle the slow processing of complex pages, complicated customization of many controls and steep learning curve. The Yii 1.0 version was released for the public on December 3, 2008, after almost one year's development. On October 2014, the complete rewrite of Yii 2.0.0 was released by keeping the earlier simplicity and feasibility while implementing the latest technologies to make it better.Features of Yii Framework
Yii Framework provides secure and professional features to create robust projects rapidly. Some of the salient features of Yii are discussed below: Easy Installation: Yii Framework can be downloaded either using Composer method or manually but developers prefer to use the Composer method as it saves a lot of time. Use Modern Technologies: Yii framework is completely based on OOPS concepts but also uses some advanced features of PHP. All classes are namespaced in Yii, which means it allows taking advantage of their autoloader. Extensible: Yii framework is highly extensible as it allows its users to use third-parties libraries by installing them with Composer and then after configuring includes them in an autoloader. Testing: Yii2 is integrated with Codecepetion. Codeception is a PHP testing framework that simplifies the process of creating the unit, functional and acceptance tests for your application. Codeception facilitates the testing configuration of an application in a simple manner. Inbuilt Security: Security is an essential feature for an application and Yii provides excellent functionality for security. It has several security components that have several methods which help to create a more secure application. It is equipped with many security measures to prevent external attacks. Less Time for Development: To develop any application, many tasks are repeated more than once. Hence, increasing the line of code and making the work tedious. But, Yii framework provides some tools that help to reduce your time on this kind of functions. One of the tools is Gii, which quickly creates a web template for:- CRUD
- Models
- Controllers
- Extensions
- Forms
Dis-advantages of Yii Framework
Every coin has two sides. Every technology comes with certain difficulties. The disadvantages of Yii are the following:- The Ajax features are not well-drafted in Yii and also require the help of JavaScript whenever needed.
- It does not provide AR queries for building up of multiple relations.
- This framework depends on static methods. Hence, because of this reason, many developers go against the framework.
- It requires previous knowledge on PHP programming language and other add-ons. This becomes difficult for the beginner programmers to master this.
Yii Structure
Yii2 Framework has a new and improved application structure. It uses Composer to manage its dependencies. Yii1 has only a basic application structure whereas Yii2 has basic as well as advanced application structure. Yii2 divides the entire application into the following sections:- Backend: For backend web development
- Common: Include standard files for all the application
- Console: Different console application
- Environments: Simple environment configurations
- Frontend: For frontend web development
- Assets–The Assets folder includes all .jsand .css files placed on the web page.
- Commands? This folder contains the controllers that can be used from the terminal itself.
- Config– The Config folder include various config files for managing database, application and application parameters.
- Mail? This folder holds the mail layout.
- Models? This folder contains the models used in the application.
- Runtime? This folder is used for storing the runtime data.
- Tests? This folder includes all the tests, i.e., acceptance, unit or functional.
- Vendor– The Vendor folder contains all the third-party packages managed by the Composer.
- Views? This folder is for views, that are displayed by the controllers.
- Layout- The layoutfolder is used for the page template.
- Web? The entry point from the web.
Above image Is only for reference.