Home  >  Article  >  Backend Development  >  PHP端如何做好API版本的控制?

PHP端如何做好API版本的控制?

WBOY
WBOYOriginal
2016-06-06 20:38:151065browse

PHP端如何做好API版本的控制?简单的说就是 1.0 和 2.0 ... 怎么更好的处理

回复内容:

PHP端如何做好API版本的控制?简单的说就是 1.0 和 2.0 ... 怎么更好的处理

目前用的TP框架,使用了二级控制器做版本管理,不知道你们都是怎么做处理的

请参考apigility

<code>$router = [
    'v1' => 'api_v1_controller',
    'v2' => 'api_v2_controller',
    ...
];

</code>

class api_v2_controller extends api_v1_controller

调用的时候

/v1/login
/v2/getUserInfo

使用类的继承机制解决这个问题吧。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn