Summary
In this chapter, we expanded upon our knowledge of everything we've learned thus far and also learned how to create RESTful JSON and XML APIs in Yii2. First, we covered the usage of yii\rest\ActiveController
, which enabled us to quickly create CRUD APIs based upon our model classes. We then covered Yii2's built-in authentication filters and covered how we can protect our resources by requiring authentication. We also covered the creation of our own authentication filters to support different authentication schemes. We then covered several other useful API classes, including yii\filters\VerbFilter, yii\filters\Cors
, and learned how to handle errors within our API. Additionally, we detailed some important information about creating our own API endpoints by extending yii\rest\Controller
.
Having covered all the information required to build applications in Yii2, we'll spend the remaining chapters of this book exploring ways in which we can enhance our applications. In...