Git Product home page Git Product logo

laravel-api-versioning's Introduction

API Versioning for Laravel

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.

laravel-api-versioning's People

Contributors

mbpcoder avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.