Download the PHP package erag/laravel-case-mapper-request without Composer
On this page you can find all versions of the php package erag/laravel-case-mapper-request. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download erag/laravel-case-mapper-request
More information about erag/laravel-case-mapper-request
Files in erag/laravel-case-mapper-request
Package laravel-case-mapper-request
Short Description Seamlessly integrate attribute-based case mapping into Laravel FormRequests — transform keys and remap validation errors effortlessly.
License MIT
Informations about the package laravel-case-mapper-request
Laravel Case Mapper Request
A Laravel package that transforms request input keys using PHP 8+ attributes. Supports formats like camelCase, snake_case, StudlyCase, UPPERCASE, enabling flexible data handling from varied sources. Ideal for backend services needing consistent input structures, regardless of client naming conventions.
📦 Designed for Laravel 10, 11, and 12 — No core modification required.
✨ Features
- 🧠 Automatically map incoming request keys to match your validation expectations
- 🧩 Attribute-based syntax using
#[MapName(...)]
- 🔄 Supports multiple naming conventions
- 🧩 Integrates seamlessly with Laravel
FormRequest
- 📚 Extendable with custom mappers
- ✅ Zero configuration, zero core hacks
- 🎨 Works with any frontend (React, Vue, etc.)
💡 Recommended: Vue or React for best developer experience
🔧 Supported Case Mappers
Mapper Class | Frontend Input | Validated As output |
---|---|---|
SnakeCaseMapper |
firstName |
first_name |
CamelCaseMapper |
first_name |
firstName |
StudlyCaseMapper |
FirstName |
first_name |
UpperCaseMapper |
FIRSTNAME |
firstname |
📦 Installation
No config file or publishing required.
Create a Form Request with Case Mapping
🧩 1. Create a Form Request class
🧩 2. Add the attribute and trait
🧩 3. Use it in a Controller
Step 3: Frontend Input Example (Vue + Inertia)
Step 4: Backend Automatically Maps It
Incoming :
Mapped for Validation output:
🧠 Defining Your Own Case Mapper
Need to support a custom casing style or transformation logic?
You can easily create your own mapper by implementing the CaseMapperContract
Just implement the contract:
Then apply to any FormRequest:
📄 License
MIT © Amit Gupta
🔗 Connect
Made with ❤️ by Amit Gupta
⭐ Found this useful? Star it on GitHub!