Api-interfaces developed by php for mobile terminals. What if the api version supports both phase I, phase II, and phase III? Please give me your thoughts.

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.