ahmedesa/laravel-api-tool-kit

Versioning

Closed this issue · 6 comments

I think it would be helpful to introduce a well thought out versioning into the package. It is known that you provide an API and it comes to breaking changes, but here you do not want to push the users of the API in front of the head, so you rely on versioning. I think this would be a useful feature in the long run. :)

Versioning could be done via HTTP header or also via url. Or a middleware that lets an API user determine the version based on a database field matching the token.

Could you please explain how it would work and what impact it might have on the system? I am eager to understand it better.

There are different approaches. Often it is a version (v1/v2) in the url, alternatively date-based. I would keep it optional what you use.

How it might work technically, or rather how others have solved it: Controller/logic depending on version - I don't think that's efficient though - how to make it more efficient would have to be reconsidered.

Maybe that one can give the version per controller/logic and has the possibility to overwrite this...

Here is a link to the Stripe documentation where they roughly describe their versioning and why they do it. GitHub does it identically by the way.

https://stripe.com/docs/api/versioning

This feature is currently in development. You can review the documentation for it here

I don't see any custom Router class to make the versioning feature through routing. A middleware may be a better solution for this package.
Also, I have a package that has similar functionality and can answer your needs. Check it out here.

Hi @hans-thomas,

Users can implement versioning in the API Generator by customizing routes in the config files. Whether using version numbers (e.g., v1, v2) or date-based formats, they have the flexibility to shape their versioning strategy. Check out the documentation here for more details.

Feel free to explore and share any questions or suggestions.

Best,

This issue has been solved with tag 2.1.3 thanks @dennisoderwald