tomlerendu / laravel-convert-case-middleware
Convert request and response keys to and from camel and snake case.
Installs: 57 339
Dependents: 0
Suggesters: 0
Security: 0
Stars: 27
Watchers: 2
Forks: 12
Open Issues: 2
Requires
- php: ^8.0|^8.1|^8.2
- ext-json: *
- laravel/framework: ^5.2|^6.0|^7.0|^8.0|^9.0|^10
Requires (Dev)
- phpunit/phpunit: ^7.5|^10
This package is auto-updated.
Last update: 2024-12-19 00:20:29 UTC
README
Convert requests from camel case to snake case. Convert responses from snake case to camel case.
Why?
Its convention to work with camel case in Javascript and snake case in PHP.
Requirements
Laravel 5.2+
Installation
composer require tomlerendu/laravel-convert-case-middleware
- Add the middleware to the appropriate group in
App\Http\Kernel.php
. For example
protected $middlewareGroups = [
'api' => [
'throttle:60,1',
'bindings',
\TomLerendu\LaravelConvertCaseMiddleware\ConvertRequestToSnakeCase::class,
\TomLerendu\LaravelConvertCaseMiddleware\ConvertResponseToCamelCase::class,
],
];