https://github.com/grohiro/laravel-camelcase-json
Convert response JSON key to camelCase
https://github.com/grohiro/laravel-camelcase-json
laravel-5-package laravel5
Last synced: 5 months ago
JSON representation
Convert response JSON key to camelCase
- Host: GitHub
- URL: https://github.com/grohiro/laravel-camelcase-json
- Owner: grohiro
- License: mit
- Created: 2017-04-20T07:03:49.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2021-01-15T22:41:43.000Z (over 4 years ago)
- Last Synced: 2025-02-06T11:55:30.701Z (5 months ago)
- Topics: laravel-5-package, laravel5
- Language: PHP
- Size: 7.81 KB
- Stars: 27
- Watchers: 4
- Forks: 4
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# laravel-camelcase-json
Convert response JSON key to camelCase.
## Usage
**In controller class**
```php
return response()->json($model);
// => ['userName' => 'foo', 'userKey' => 'bar', ...]
```## Requirements
- Laravel 5+
## Install
```bash
$ 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**
```php
'provider' => [
// default providers
// ...
Grohiro\LaravelCamelCaseJson\CamelCaseJsonResponseServiceProvider::class,
],
```