Download the PHP package teners/laravel-key-case without Composer
On this page you can find all versions of the php package teners/laravel-key-case. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download teners/laravel-key-case
More information about teners/laravel-key-case
Files in teners/laravel-key-case
Package laravel-key-case
Short Description Middleware for automatic case transformation of request and response data key in Laravel applications.
License MIT
Homepage https://github.com/Teners-net/laravel-key-case#readme
Informations about the package laravel-key-case
Laravel Key Case
A high-performance Laravel package that automatically transforms request and response data keys between different naming conventions (camelCase โ snake_case, kebab-case, etc.).
๐ฏ Why Laravel Key Case?
Bridge the gap between frontend and backend naming conventions effortlessly. Work with your preferred naming style in both JavaScript (camelCase) and PHP (snake_case) without manual conversion.
๐ฆ Installation
Install via Composer:
Publish Configuration (Optional)
Quick Start
Laravel 11
Register middleware in bootstrap/app.php
:
Older laravel versions
Add to app/Http/Kernel.php
:
Configuration
The package works with zero configuration, but you can customize it by publishing the config file:
๐ Usage Examples
Basic API Transformation
Frontend (JavaScript)
Backend (Laravel)
Route-Specific Control
Supported Case Types
Case Type | Example | Use Case |
---|---|---|
camel |
firstName |
JavaScript, JSON APIs |
snake |
first_name |
PHP, Database columns |
kebab |
first-name |
URLs, CSS classes |
studly |
FirstName |
Class names |
lower |
firstname |
Simple keys |
upper |
FIRSTNAME |
Constants |
ucfirst |
Firstname |
Sentences |
ucwords |
First Name |
Titles |
singular |
user (from users ) |
Model names |
plural |
users (from user ) |
Collections |
slug |
first-name |
URLs |
title |
First Name |
Display text |
Error Resilience
- Non-blocking - errors won't break your requests
๐งช Testing
Run the test suite:
Contributions
Contributions are welcome via Pull Requests on Github.
- Please document any change you made as neccesary in the README.md.
- Follow PSR-12 coding standards
- Write tests for new features
- Update documentation for any changes
- Make one pull request per feature/fix
- Ensure all tests pass
Issues
Please report any issue you encounter in using the package through the Github Issues tab.
When reporting issues, please include:
- Laravel version
- PHP version
- Package version
- Code example
- Error messages
Testing
To run tests, use:
Credits
Contributors list will be added here
License
The MIT License (MIT). Please see License File for more information.
Made with โค๏ธ by Teners - if this package helped you โญ Star us on GitHub