Looking to hire Laravel developers? Try LaraJobs

laravel-convert-case-middleware maintained by tomlerendu

Description
Convert request and response keys to and from camel and snake case.
Author
Last update
2024/01/18 23:19 (dev-master)
License
Links
Downloads
73 561

Comments
comments powered by Disqus

Laravel Convert Case Middleware

Actions Status

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

  1. composer require tomlerendu/laravel-convert-case-middleware
  2. 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,
    ],
];