Download the PHP package rizkussef/laravel-snake-to-camel-case without Composer
On this page you can find all versions of the php package rizkussef/laravel-snake-to-camel-case. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download rizkussef/laravel-snake-to-camel-case
More information about rizkussef/laravel-snake-to-camel-case
Files in rizkussef/laravel-snake-to-camel-case
Package laravel-snake-to-camel-case
Short Description A Laravel middleware package to automatically convert API response keys from snake_case to camelCase for frontend compatibility, and optionally convert request keys from camelCase to snake_case
License MIT
Informations about the package laravel-snake-to-camel-case
πππ« Laravel Snake-to-Camel Case Middleware
β¨ What is this?
A Laravel package that automatically converts API keys between snake_case
and camelCase
:
β Incoming Requests: Converts camelCase
β snake_case
(for Eloquent models & DB consistency).
β Outgoing Responses: Converts snake_case
β camelCase
(for React, Vue, or any frontend apps).
Perfect for clean API responses and JavaScript-friendly keys! π
β Features
-
π Two-way conversion: Request & Response.
-
π Works on nested arrays & JSON.
-
π Applies to all routes or only API routes (configurable).
-
β‘ Plug & play using Laravelβs package auto-discovery.
- π Fully configurable via
config/snake-to-camel.php
.
π¦ Installation
Require the package via Composer:
βοΈ Configuration
Publish the config file:
Then edit config/snake-to-camel.php
:
β
You can also override these settings in .env
:
π How It Works
β Example Request (Frontend β Laravel)
Before:
After Middleware (Laravel receives):
β Example Response (Laravel β Frontend)
Before:
After Middleware (Frontend receives):
π Usage
No manual registration needed. Laravel auto-discovers the service provider:
Rizkussef\LaravelSnakeToCamelCase\Providers\SnakeToCamelServiceProvider
The middleware automatically applies to:
-
β All routes (if
apply_to
=all
) - β
Only API routes (if
apply_to
=api
)
π Requirements
-
PHP 8.1+
- Laravel 10.x | 11.x
π License
This package is open-source under the MIT license.
See LICENSE for details.
β Support
If you like this package, please star the repo on GitHub β
Contributions and PRs are welcome!