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
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!