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

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

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-06 20:38:15
Original
1179 people have browsed it

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>
Copy after login

class api_v2_controller extends api_v1_controller

调用的时候

/v1/login
/v2/getUserInfo

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

Related labels:
Statement of this Website
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template