grohiro / laravel-camelcase-json

Convert response JSON key to camelCase
MIT License
27 stars 4 forks source link
laravel-5-package laravel5

laravel-camelcase-json

Convert response JSON key to camelCase.

Usage

In controller class

return response()->json($model);
// => ['userName' => 'foo', 'userKey' => 'bar', ...]

Requirements

Install

$ composer require 'grohiro/laravel-camelcase-json' '~1.0'
# Laravel 5.7+
$ composer require 'grohiro/laravel-camelcase-json' '~2.0'

Add the service provider.

config/app.php

'provider' => [
    // default providers
    // ...

    Grohiro\LaravelCamelCaseJson\CamelCaseJsonResponseServiceProvider::class,
],