The Definitive Guide to Yii 2.0

The Definitive Guide to Yii 2.0

The Definitive Guide to Yii 2.0

This tutorial is released under the Terms of Yii Documentation.

All Rights Reserved.

2014 (c) Yii Software LLC.



Active Record Yii 2

User Rating: 5 / 5

Star ActiveStar ActiveStar ActiveStar ActiveStar Active

Active Record

Active Record provides an object-oriented interface for accessing and manipulating data stored in databases. An Active Record class is associated with a database table, an Active Record instance corresponds to a row of that table, and an attribute of an Active Record instance represents the value of a particular column in that row. Instead of writing raw SQL statements, you would access Active Record attributes and call Active Record methods to access and manipulate the data stored in database tables.

Query Builder Yii 2

User Rating: 5 / 5

Star ActiveStar ActiveStar ActiveStar ActiveStar Active

Query Builder

Built on top of Database Access Objects, query builder allows you to construct a SQL query in a programmatic and DBMS-agnostic way. Compared to writing raw SQL statements, using query builder will help you write more readable SQL-related code and generate more secure SQL statements.

Database Access Objects in Yii 2

User Rating: 5 / 5

Star ActiveStar ActiveStar ActiveStar ActiveStar Active

Database Access Objects

Built on top of PDO, Yii DAO (Database Access Objects) provides an object-oriented API for accessing relational databases. It is the foundation for other more advanced database access methods, including query builder and active record.

When using Yii DAO, you mainly need to deal with plain SQLs and PHP arrays. As a result, it is the most efficient way to access databases. However, because SQL syntax may vary for different databases, using Yii DAO also means you have to take extra effort to create a database-agnostic application.

Dependency Injection Container Yii 2

User Rating: 5 / 5

Star ActiveStar ActiveStar ActiveStar ActiveStar Active

Dependency Injection Container

A dependency injection (DI) container is an object that knows how to instantiate and configure objects and all their dependent objects. Martin Fowler's article has well explained why DI container is useful. Here we will mainly explain the usage of the DI container provided by Yii.

Service Locator Yii 2

User Rating: 5 / 5

Star ActiveStar ActiveStar ActiveStar ActiveStar Active

Service Locator

A service locator is an object that knows how to provide all sorts of services (or components) that an application might need. Within a service locator, each component exists as only a single instance, uniquely identified by an ID. You use the ID to retrieve a component from the service locator.

In Yii, a service locator is simply an instance of [[yii\di\ServiceLocator]] or a child class.

Class Autoloading Yii 2

User Rating: 5 / 5

Star ActiveStar ActiveStar ActiveStar ActiveStar Active

Class Autoloading

Yii relies on the class autoloading mechanism to locate and include all required class files. It provides a high-performance class autoloader that is compliant with the PSR-4 standard. The autoloader is installed when you include the Yii.php file.

Subcategories