Versioning your REST API with Laravel

Gabriel Anhaia
Dev Warlocks
Published in
5 min readMar 28, 2020

--

If you are not versioning your REST API you should take a look at this post and learn all its benefits and how to apply it in real projects using Laravel Framework.

What does it mean “versioning an API”?

Imagine the following situation, you are building an API that will be consumed by an APP developed for IOS/Android, one of the endpoints in your API who has the objective to return a list of users from your system to be viewed on the APP. The URL to consume this list of users is “GET https://www.my-website-exemple.com/api/users", the return of this endpoint is:

[{
"name": "Test User Name 1",
"email": "Test Email 1",
"phone": "+1353832123323233"
},{
....}]

When you finished the endpoint, the mobile developer integrates it with the APP and submits it to App Store and Play Store, after that, loads of people download it on their mobile phones and start using it.

After 1 month that the App is available for download, your company is sold for a Brazilian company, and they decide that the API should start retrieving the name of the fields (API) in Portuguese, it is because the new team in Brazil don’t speak English. At first glance, it looks quite simple, we just have to update the API and update the APPs to be able to read the new fields of the…

--

--

Gabriel Anhaia
Dev Warlocks

Software Engineer (Billie GmbH), Freelancer, and Author. Germany/Brazil. Book Design Patterns em PHP: https://goo.gl/NNDZqe