Pages

12/11/15

Integrating WordPress and Yii2

In this article, we are going to integrate Yii2 and WordPress applications. It can be useful in case when the WordPress app is a client and the Yii2 app is an API provider. Yes, you can say it can be done with WordPress natively without using of Yii2, but Yii2 Framework has a lot of built-in instruments that helps to create an API ASAP. ОК. Let's start.

12/6/15

Getting selected fields from the relation in Yii2

During building the REST API sometimes, we need to get related objects with the main object(s).

The main benefit of this approach is getting of all needed data at one query. Just agree it's cool! Let's try to implement this feature in Yii2.

By default, Yii2 has an implementation to get the related objects, but it fetches the whole record which can be too complex. And when you need to get for example only the user's name or some other attribute you will get all fields.