Published on Sep 21, 2019
Yii is a high-performance component-based PHP framework for developing large-scale Webapplications. It enables maximum reusability in Web programming and can signi?cantly accelerate the development process.
The name Yii (pronounced as Yee or [ji:] ) standsfor easy, efficient and extensible Yii is a generic Web programming framework that can be used for developing virtually all sorts of Web applications. Because it is light-weighted and equipped with sophisticated caching solutions, it is especially suitable for developing high-traffic applications, such as portals, forums, content management systems (CMS), e-commerce systems, etc
Like most PHP frameworks, Yii is an MVC framework. Yii excels over other PHP frameworks in that it is e ? cient, feature-rich and clearly-documented. Yii is carefully designed from the beginning to ?t for serious Web application development. It is neither a byproduct of some pro ject nor a conglomerate of third-partywork. It is the result of the authors' rich experience of Web application development and the investigation and re?ection of the most popular Web programming frameworks and applications.
Introduction of Yii Framework
Installation of Yii mainly involves the following two steps:
Download Yii Framework from yiiframework.com.
Unpack the Yii release ?le to a Web-accessible directory
After installing Yii, you may want to verify that your server satis?es all the requirementsof using Yii. You can do so by accessing the requirement checker script at the followingURL in a Web browser:
The minimum requirement by Yii is that your Web server supports PHP 5.1.0 or above. Yii has been tested with Apache HTTP server on Windows and Linux operating systems.
It may also run on other Web servers and platforms provided PHP 5 is supported.
Yii implements the model-view-controller (MVC) design pattern which is widely adopted in Web programming. MVC aims to separate business logic from user interface considerations so that developers can more easily change each part without affecting the other. In MVC, the model represents the information (the data) and the business rules; the view contains elements of the user interface such as text, form inputs; and the controller manages the communication between the model and the view. Besides MVC, Yii also introduces a front-controller, called application, which represents the execution context of request processing. Application resolves the user request and dispatches it to an appropriate controller for further handling.
Typical Work?ow :
The following diagram shows a typical work?ow of an Yii application when it is handling a user request
1. A user makes a request with the URL http://www.example.com/index.php?r=post/ show&id=1 and the Web server handles the request by executing the bootstrap script index.php .
2. The bootstrap script creates an application instance and runs it.
3. The application obtains the detailed user request information from an application component named request .
4. The application determines the requested controller and action with the help of an application component named urlManager . For this example, the controller is post which refers to the PostController class; and the action is show whose actual meaning is determined by the controller.
5. The application creates an instance of the requested controller to further handle the user request. The controller determines that the action show refers to a method named actionShow in the controller class. It then creates and executes ?lters (e.g. access control, benchmarking) associated with this action. The action is executed if it is allowed by the ?lters.
6. The action reads a Post model whose ID is 1 from the database.
7. The action renders a view named show with the Post model.
8. The view reads and displays the attributes of the Post model.
9. The view executes some widgets.
10. The view rendering result is embedded in a layout.
11. The action completes the view rendering and displays the result to the user.