tomlerendu/laravel-convert-case-middleware

Convert request and response keys to and from camel and snake case.

1.1.4 2024-01-18 22:19 UTC

This package is auto-updated.

Last update: 2024-10-19 00:00:46 UTC


README

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,
    ],
];