PHPackages                             bbrothers/http-transitions - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. bbrothers/http-transitions

ActiveLibrary[HTTP &amp; Networking](/categories/http)

bbrothers/http-transitions
==========================

API versioning with transition stages (migrations) based on a request header.

v0.5.0(7y ago)28.1kMITPHPPHP ^7.1

Since Aug 31Pushed 7y ago1 watchersCompare

[ Source](https://github.com/bbrothers/http-transitions)[ Packagist](https://packagist.org/packages/bbrothers/http-transitions)[ Docs](https://github.com/bbrothers/http-transitions)[ RSS](/packages/bbrothers-http-transitions/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (6)Dependencies (7)Versions (7)Used By (0)

http-transitions
================

[](#http-transitions)

[![Latest Version on Packagist](https://camo.githubusercontent.com/5966362e9fdc0a0c868a1a32d98ea091688fb109d5de093173015e9fa546e7c7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6262726f74686572732f687474702d7472616e736974696f6e732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/bbrothers/http-transitions)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/7d43ed7b3bac6b40591e7434016941fdfe4ad064bed704279c305b064464755a/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6262726f74686572732f687474702d7472616e736974696f6e732f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/bbrothers/http-transitions)[![Coverage Status](https://camo.githubusercontent.com/d92788b501fa41ddf328b65aa2e9e25f983062a4f273dde4c18eb2c760549bb5/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f6262726f74686572732f687474702d7472616e736974696f6e732e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/bbrothers/http-transitions/code-structure)[![Quality Score](https://camo.githubusercontent.com/930d199cffdc14d76cc094be9ecb277027bf65824dc1f74758f44da258575935/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6262726f74686572732f687474702d7472616e736974696f6e732e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/bbrothers/http-transitions)[![Total Downloads](https://camo.githubusercontent.com/8c30a440c6e8f5233daa15e65a38f121132ae629855386bec75f94490c7249dd/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6262726f74686572732f687474702d7472616e736974696f6e732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/bbrothers/http-transitions)

A package for transitioning HTTP requests and responses based on a version header.

Release updates to your API schema without breaking existing clients by creating `Transition` classes that transition the request and/or response to match the previously expected result. Each layer of transitions only needs to convert the current version to match the previous version, from there the request and response will be piped through the subsequent layers until they match the version requested in the `Api-Version` header.

Largely based on [Stripe's API versioning](https://stripe.com/blog/api-versioning) article.

Install
-------

[](#install)

```
$ composer require bbrothers/http-transitions
```

#### Middleware

[](#middleware)

In your `app/Http/Kernel.php` file, add:

```
protected $middleware = [
    Transitions\TransitionMiddleware::class
];
```

#### Service Provider

[](#service-provider)

For Laravel 5.4, in your `config/app.php` file, in the `providers` array, add:

```
Transitions\TransitionProvider::class
```

#### Publish Config

[](#publish-config)

```
php artisan vendor:publish --provider="Transitions\TransitionProvider"
```

Usage
-----

[](#usage)

Add version numbers and an array of `Transition` classes to the `transitions.php` file.

```
return [
   'headerKey' => 'Api-Version',
   'transitions'    => [
       '20160101' => [
           FullNameToNameTransition::class,
           NameToFirstNameLastNameTransition::class,
           BirthDateTransition::class,
       ],
       '20150101' => [
           FirstNameLastNameToFullNameTransition::class,
       ],
   ],
]
```

Create a transition:

```
class NameToFirstNameLastNameTransition extends Transition
{

    public function transformResponse(Response $response) : Response
    {
        $content = json_decode($response->getContent(), true);
        $content = array_diff_key(array_merge($content, $content['name']), ['name' => true]);

        return $response->setContent(json_encode($content));
    }
}
```

Transition Generators
---------------------

[](#transition-generators)

```
$ php artisan make:transition NameToFirstNameLastNameTransition
```

Optionally, the `--request-only` or `--response-only` flags can be added to create a transform that only generates a `transformRequest` or `transformResponse` method respectively.

Change log
----------

[](#change-log)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 96.6% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~118 days

Recently: every ~147 days

Total

6

Last Release

2581d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2eb217c8629a63fa37a8b673d77f4c95137a5399c98a9c25463afee2a5416e93?d=identicon)[bbrothers](/maintainers/bbrothers)

---

Top Contributors

[![bbrothers](https://avatars.githubusercontent.com/u/2477338?v=4)](https://github.com/bbrothers "bbrothers (28 commits)")[![JCook21](https://avatars.githubusercontent.com/u/858371?v=4)](https://github.com/JCook21 "JCook21 (1 commits)")

---

Tags

api-versioninglaravelmigrationshttpmiddlewareapischematransitionmigrationsversioning

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/bbrothers-http-transitions/health.svg)

```
[![Health](https://phpackages.com/badges/bbrothers-http-transitions/health.svg)](https://phpackages.com/packages/bbrothers-http-transitions)
```

###  Alternatives

[api-platform/laravel

API Platform support for Laravel

59126.4k6](/packages/api-platform-laravel)[tomschlick/request-migrations

HTTP Request Migrations

1844.5k](/packages/tomschlick-request-migrations)[pusher/pusher-http-laravel

\[DEPRECATED\] A Pusher bridge for Laravel

400509.0k3](/packages/pusher-pusher-http-laravel)[chadicus/slim-oauth2

OAuth2 routes, middleware and utilities for use within a Slim Framework API

129365.9k3](/packages/chadicus-slim-oauth2)[dragon-code/laravel-http-logger

Logging incoming HTTP requests

319.8k3](/packages/dragon-code-laravel-http-logger)[laragear/json

Easily retrieve and manipulate `Json` across your application.

363.5k](/packages/laragear-json)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
