定制 mbpcoder/laravel-api-versioning 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

mbpcoder/laravel-api-versioning

最新稳定版本:v1.3

Composer 安装命令:

composer require mbpcoder/laravel-api-versioning

包简介

Enable Api Versioning for Laravel

README 文档

README

Latest Version on Packagist Total Downloads

This is a very simple package to support API versioning in Laravel 8,7,6,5. this package provide fallback API capability for Laravel.

Features

  • If you have one API version it will automatically disable
  • You can disable package in config files
  • You can add countless API Versions in config file
  • Does not affect routes except API

Let's Code!

If you call for /{version_number}/version every API have it is own route. If you call for /v2.1/hello-world it will try to call v2.1 and if it does not find a route will search v2 then if the version 2 also does not have the routes it will fallback to v1

// laravel route file
Route::prefix('v2.1')->group(function () {
    Route::get('version', function () {
        return 'API v2.1';
    });
});

Route::prefix('v2')->group(function () {
    Route::get('version', function () {
        return 'API v2';
    });
});

Route::prefix('v1')->group(function () {
    Route::get('version', function () {
        return 'API v1';
    });

    Route::get('hello-world', function () {
        return 'Hello World!';
    });
});

Installation

You can install the package via composer:

composer require mbpcoder/laravel-api-versioning

Usage

Publish config file

php artisan vendor:publish --provider="MbpCoder\ApiVersioning\ApiVersioningServiceProvider"

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Credits

License

The MIT License (MIT). Please see License File for more information.

Laravel Package Boilerplate

This package was generated using the Laravel Package Boilerplate.

统计信息

  • 总下载量: 175.83k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 19
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 19
  • Watchers: 2
  • Forks: 5
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-06-17