API Versioning

未匹配的标注

Since Laravel does not support API versioning, apiato provide a very easy way to implement versioning for your API.

How it works

Create:

When creating a new API endpoint, specify the version number in the route file name following this naming format {endpoint-name}.{version-number}.{documentation-name}.php.

Example:

  • MakeOrder.v1.public.php
  • MakeOrder.v2.public.php
  • ListOrders.v1.private.php
    Use:

Automatically the endpoint inside that route file will be accessible by adding the version number to the URL.

Example:

  • http://api.apiato.develop/v1/register
  • http://api.apiato.develop/v1/orders
  • http://api.apiato.develop/v2/stores/123

Version the API in header instead of URL

First remove the URL version prefix:
1、Edit app/Ship/Configs/apiato.php, set prefix to 'enable_version_prefix' => 'false',.
2、Implement the Header versioning anyway you prefer. (this is not implemented in Apiato yet. Consider a contribution).

本文章首发在 LearnKu.com 网站上。

上一篇 下一篇
《L03 构架 API 服务器》
你将学到如 RESTFul 设计风格、PostMan 的使用、OAuth 流程,JWT 概念及使用 和 API 开发相关的进阶知识。
《L02 从零构建论坛系统》
以构建论坛项目 LaraBBS 为线索,展开对 Laravel 框架的全面学习。应用程序架构思路贴近 Laravel 框架的设计哲学。
讨论数量: 0
发起讨论 只看当前版本


暂无话题~