Laravel Convert Case Middleware
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 wedamir/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,
],
];