RESTful interface planning

recently, a new project needs to redesign a set of interfaces for app .
We use PHP + laravel
. The initial design is
abc.com/api/v1 as the online access portal
qa.abc.com/api/v1 as the access portal to the test environment
pre.abc.com/api/v1 as the access portal to the pre-release environment
but looking at the design specifications on the Internet. Compare and recommend another way
api.abc.com and
define version in header
Design another set of interfaces based on this specification
api.abc.com as the online entrance
qa-api.abc.com as the entrance to the test environment
pre-api.abc.com as the entrance to the pre-release environment
and then add version

to header .

but this design brings a problem. app pc wap share the same set of codes. For several specific domain names of api , you need to map these specific domain names to the same set of routes. I feel that this design is very distorted.
another problem is that if I use the api/v1 design method, I can generate different controllers from different versions. However, if we use the scheme of header version , will different data structures be generated within the same controller according to the value of version , and will the code complexity inside the controller become higher and higher with the development of business?
I hope you will not hesitate to comment!

Oct.11,2021

online is not necessarily right, what is suitable is good. I think yours is very good.


the version is reflected in url or header, which does not affect your controller structure.
can abc.com/api/v1 point to / api/controller/v1/XXXController, but can't the added version of header point to it?
of course, I suggest that versioning is done by folder rather than by version inside the controller.


just distinguish by folder.
online articles only provide a choice and ideas, how to choose, depending on your own real environment.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b42595-2c60d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b42595-2c60d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?