Yii – Testing
When we write a PHP class, we debug it step by step or use die or echo statements to verify how it works. If we develop a web application, we…
When we write a PHP class, we debug it step by step or use die or echo statements to verify how it works. If we develop a web application, we…
By overriding fields() and extraFields() methods, you can define what data can be put into a response. The difference between these two methods is that the former defines the default set of…
The controller class extends from the yii\rest\ActiveController class, which implements common RESTful actions. We specify the $modelClass property so that the controller knows which model to use for manipulating data. Step 1 − Create a…
Yii provides the following useful features for implementing RESTful APIs − Quick prototypingCustomizable object serializationResponse format (supporting JSON and XML by default)Formatting of collection data and validation errorsEfficient routingSupport for…
Theming helps you replace a set of views with another one without the need of modifying original view files. You should set the theme property of the view application component to use…
During the developing of a database-driven application, the database structure evolves with the source code. Yii provides the database migration feature that allows you to keep track of database changes. Yii provides…
Active Record provides an object-oriented API for accessing data. An Active Record class is associated with a database table. Yii provides the Active Record support for the following relational databases…
Query builder allows you to create SQL queries in a programmatic way. Query builder helps you write more readable SQL-related code. To use query builder, you should follow these steps…
To execute an SQL query, you should follow these steps − Create an yii\db\Command with an SQL query.Bind parameters (not required)Execute the command. Step 1 − Create a function called actionTestDb in the SiteController. public function…
Yii DAO (Database Access Object) provides an API for accessing databases. It also serves as the foundation for other database access methods: active record and query builder. Yii DAO supports…