In the guide for Yii 2 it is said:
While not required, it is recommended that you develop your RESTful APIs as a separate application, different from yo
This article explain the idea and the why , also it provide you a starter project called "yii2-advanced-api": http://budiirawan.com/setup-restful-api-yii2/