Mobile End, now the development enters the end of the third phase. However, the Server API version is hard to handle. v3.0 still has many changes to v1.0. How can we support the 1-3 versions? If there is an interface file in phase I, there will be a minor version. I would like to ask you to give me a mobile terminal. Now the development is at the end of the three phases. However, the Server API version is hard to handle. There are still many changes to v = 3.0 to v = 1.0. How can we support the 1-3 versions? If there is an interface file in phase I, there will be a minor version. I would like to ask you to give me a design idea. Evaluate and learn
Supplement: currently, TP is used for development. For example, ApiAction. class. php. This is the Action of the interface, which contains different methods. There are many ways to change the content of a major version. The minor version will also change the method.
In addition, the development language php uses the tinkphp framework.
Reply content:
Mobile End, now the development enters the end of the third phase. However, the Server API version is hard to handle. There are still many changes to v = 3.0 to v = 1.0. How can we support the 1-3 versions? If there is an interface file in phase I, there will be a minor version. I would like to ask you to give me a design idea. Evaluate and learn
Supplement: currently, TP is used for development. For example, ApiAction. class. php. This is the Action of the interface, which contains different methods. There are many ways to change the content of a major version. The minor version will also change the method.
In addition, the development language php uses the tinkphp framework.
Http://www.ruanyifeng.com/blog/2014/05/restful_api.html
3. Versioning should put the API version number into the URL. Https://api.example.com/v1/
The previous versions should be retained for compatibility.
You can try to use a simple MVC mechanism. The client transmits the version number, such as api. php? V = 3.0 & method = foo/bar, then the Controller calls foo. php to instantiate the bar_3_0 method of the foo class, and provides the foo Model with data support of the corresponding version.
If there are many versions and the changes are large, it is difficult to maintain and launch all versions and use nginx to distribute requests.