Versioning

If you build your API unversioned, it's terrifying. Let's imagine you're pushing out a breaking change – basically any change that runs counter to what client developers have planned for, such as renaming or deleting a parameter or changing the format of the response – you run the risk of bringing down many, if not all, of your customers' systems, leading to angry support calls or, worse, massive churn. That's why you have to keep your API versioned. In Yii2, versioning can be easily done through modules, so versions will be represented as isolated block of code.

Getting ready

Repeat all steps from the Creating a REST server recipe's Getting ready and How to do it… sections.

How to do it…

  1. Create the following structure in your app folder. ...

Get Yii2 Application Development Cookbook - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.