Home  >  Article  >  PHP Framework  >  Where is yii2 strong?

Where is yii2 strong?

(*-*)浩
(*-*)浩Original
2019-12-30 10:34:442288browse

Where is yii2 strong?

1. Simple installation

For web developers, time is money. No one wants to waste their time on tedious installation and configuration.                                                                                                                                      (Recommended learning: yii framework )

Composer will handle the installation program. I prefer to stick with the basic app template even though I have a separate front-end and back-end component on my site.

Instead, I chose to use a module for the backend portion of my site. (Yii modules are the best representation of mini-applications, used to embed into your main application.)

Note: The directory references in many of the examples below use the directory structure of a simple template.

2. Use modern technology

Yii is a pure OOP framework, which makes full use of some of the more advanced features of PHP, including delayed static binding, SPL classes and interfaces, and anonymous functions.

All classes are namespaced and allow you to take advantage of their PSR-4 compliant autoloader. In other words, including the HTML auxiliary classes in Yii, it is equally simple:

use yii\helpers\Html;

Yii can also define aliases to help simplify your namespace. In the above example, the use statement will load a class definition, and the default path in the directory is /vendor/yiisoft/yii2/helpers. This alias is defined in line 79 of the BaseYii class:

public static $aliases = ['@yii' => __DIR__];

3. High scalability

Yii is like a suit, it looks big, But it's actually easy to adjust to suit your needs. Virtually every component of the framework is extensible. A simple example is adding a unique body ID to your view.

4. Encourage testing

Yii and Codeception are closely connected. Codeception is an amazing PHP testing framework that helps simplify the process of creating widgets, functional tests, and acceptance tests for your applications.

5. Simplify security

Security is an important part of any web application. Fortunately, Yii has some great features to help you solve it. troubles in this regard.

Yii comes with a secure application component, which exposes several methods to help create a more secure application. Some of the more useful methods are as follows:

·generatePasswordHash: Generates a secure one-way hash function from a password and random factors. This method compiles a random factor for you and then creates a one-way hash function from the string provided by the PHP crypt function.

· validatePassword: For generatePasswordHash, this is a companion function and allows you to check whether the user-supplied password matches your stored hash function.

·generateRandomKey: Allows you to create a random string of any length.

6. Shorten development time

Most projects will involve certain repetitive tasks, and no one wants to waste time. Yii provides some tools that can help you spend less time on these tasks and more time on customizing applications that satisfy customers.

Among these tools, one called "Gii" is the most powerful. Gii is a web-based scaffolding code tool that allows you to quickly create code templates:

·模型
·控制器
·形式
·模块
·扩展
·CRUD控制器行为和视图

Gii is highly configurable. You can set it to load only under specific circumstances.

7. Easy to adjust for optimal performance

Everyone knows that if a website is slow, it will easily make users dissatisfied, so Yii provides several tools To help you "squeeze" more speed from your application.

All Yii's caching components are extended from yii/caching/Cache, you can choose any one you want while using a common API extended caching system. You can even register multiple cache components. Yii currently supports database and file caching, APC, Memcache, Redis, WinCache, XCache and Zend data caching.

By default, if you are using Active Record, then Yii will run an additional query to determine the tables involved in generating the model's schema

The above is the detailed content of Where is yii2 strong?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn