PHPackages                             phpsa/laravel-case-remapping - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. phpsa/laravel-case-remapping

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

phpsa/laravel-case-remapping
============================

Methods to allow the mapping of cases to snake / camel for input / output

v1.0.1(4y ago)425MITPHPPHP ^8.0

Since Jul 27Pushed 4y ago1 watchersCompare

[ Source](https://github.com/phpsa/laravel-case-remapping)[ Packagist](https://packagist.org/packages/phpsa/laravel-case-remapping)[ Docs](https://github.com/phpsa/laravel-case-remapping)[ GitHub Sponsors](https://github.com/phpsa)[ RSS](/packages/phpsa-laravel-case-remapping/feed)WikiDiscussions main Synced today

READMEChangelog (2)Dependencies (13)Versions (3)Used By (0)

Methods to allow the mapping of cases to snake / camel for input / output
=========================================================================

[](#methods-to-allow-the-mapping-of-cases-to-snake--camel-for-input--output)

[![Latest Version on Packagist](https://camo.githubusercontent.com/1c2199aee39bcfd2a4b2b4f0c6968ee85c30fda2465c3f0e8f75b73a26cdadd4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f70687073612f6c61726176656c2d636173652d72656d617070696e672e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/phpsa/laravel-case-remapping)[![GitHub Tests Action Status](https://camo.githubusercontent.com/d89d901771b0ebbabc1b724e2d1433ab3c54adec8fe2dcdc6c42f7b09950514d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f70687073612f6c61726176656c2d636173652d72656d617070696e672f72756e2d74657374733f6c6162656c3d7465737473)](https://github.com/phpsa/laravel-case-remapping/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/58a459b6fd7b607b91384ab12929c2c15c08a7c7c092600ae93f50fc31a75a14/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f70687073612f6c61726176656c2d636173652d72656d617070696e672f436865636b253230262532306669782532307374796c696e673f6c6162656c3d636f64652532307374796c65)](https://github.com/phpsa/laravel-case-remapping/actions?query=workflow%3A%22Check+%26+fix+styling%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/8121c3faf06af47340b04ce7dd4bf6060e4bd279441cd36fcfa692d36a5cf69d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f70687073612f6c61726176656c2d636173652d72656d617070696e672e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/phpsa/laravel-case-remapping)

This is where your description should go. Limit it to a paragraph or two. Consider adding a small example.

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require phpsa/laravel-case-remapping
```

Usage - Middlware for incomming requests
----------------------------------------

[](#usage---middlware-for-incomming-requests)

Add as a middleware: `Phpsa\LaravelCaseRemapping\Http\Middleware\SnakeCaseInputs` to your route eg:

```
Route::post('xxx',[...])->withMiddleware(\Phpsa\LaravelCaseRemapping\Http\Middleware\SnakeCaseInputs::class)
```

in your controllers constructor:

```
public function __construct()
{
    $this->middleware(\Phpsa\LaravelCaseRemapping\Http\Middleware\SnakeCaseInputs::class);
}
```

Or globally via the `app/Http.Kernal.php` file

```
protected $middlewareGroups = [
        'web' => [
            \App\Http\Middleware\EncryptCookies::class,
            \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
            \Illuminate\Session\Middleware\StartSession::class,
            // \Illuminate\Session\Middleware\AuthenticateSession::class,
            \Illuminate\View\Middleware\ShareErrorsFromSession::class,
            \App\Http\Middleware\VerifyCsrfToken::class,
            \Illuminate\Routing\Middleware\SubstituteBindings::class,
        ],

        'api' => [
            'throttle:api',
            \Illuminate\Routing\Middleware\SubstituteBindings::class,
            \Phpsa\LaravelCaseRemapping\Http\Middleware\SnakeCaseInputs::class
        ],
    ];
```

Usage - Response wrapping for your Transformers / Response objects
------------------------------------------------------------------

[](#usage---response-wrapping-for-your-transformers--response-objects)

add the following trait to your resource: `\Phpsa\LaravelCaseRemapping\Http\Resources\WithAcceptedCase`

then in your `toArray` method change to per example

```
public function toArray($request){
    $data = parent::toArray($request);

    ... // any other modifications

    return $this->toAcceptCase($request, $data);
}

```

based on the header value for `X-Accept-Case-Type` passed to the request it will reaturn one of the following `camel`, `kebab`, `snake`

Usage - Collection methods
--------------------------

[](#usage---collection-methods)

This packages includes 3 collecion macros:

- **snakeKeys** - will convert all array keys to snake case
- **camelKeys** - will convert all array keys to camel case
- **kebabKeys** - will convert all array keys to kebab case

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

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

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Craig Smith](https://github.com/phpsa)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 68.8% 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 ~15 days

Total

2

Last Release

1731d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/bbe4c97ef26aca9d6792775ea44a4c83215881b158f2d3894279c7b73bedda3c?d=identicon)[phpsa](/maintainers/phpsa)

---

Top Contributors

[![craigAtCD](https://avatars.githubusercontent.com/u/152445143?v=4)](https://github.com/craigAtCD "craigAtCD (11 commits)")[![phpsa](https://avatars.githubusercontent.com/u/952595?v=4)](https://github.com/phpsa "phpsa (3 commits)")[![semantic-release-bot](https://avatars.githubusercontent.com/u/32174276?v=4)](https://github.com/semantic-release-bot "semantic-release-bot (2 commits)")

---

Tags

laravelphpsalaravel-case-remapping

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Type Coverage Yes

### Embed Badge

![Health badge](/badges/phpsa-laravel-case-remapping/health.svg)

```
[![Health](https://phpackages.com/badges/phpsa-laravel-case-remapping/health.svg)](https://phpackages.com/packages/phpsa-laravel-case-remapping)
```

###  Alternatives

[spatie/laravel-data

Create unified resources and data transfer objects

1.7k28.9M626](/packages/spatie-laravel-data)[spatie/laravel-livewire-wizard

Build wizards using Livewire

4061.0M4](/packages/spatie-laravel-livewire-wizard)[hirethunk/verbs

An event sourcing package that feels nice.

513162.9k6](/packages/hirethunk-verbs)[worksome/exchange

Check Exchange Rates for any currency in Laravel.

123544.7k](/packages/worksome-exchange)[ralphjsmit/livewire-urls

Get the previous and current url in Livewire.

82270.3k4](/packages/ralphjsmit-livewire-urls)[hydrat/filament-table-layout-toggle

Filament plugin adding a toggle button to tables, allowing user to switch between Grid and Table layouts.

6292.3k1](/packages/hydrat-filament-table-layout-toggle)

PHPackages © 2026

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