mattketmo/camel
Laravel-friendly utilities for converting strings, keys, and arrays between camelCase, snake_case, StudlyCase and more. Handy for normalizing request/response payloads, config keys, and API data with simple helpers and minimal setup.
mattketmo/camel package is a minimal, single-purpose library for case transformations (e.g., snake_case ↔ camelCase/PascalCase). It aligns well with Laravel’s modular ecosystem, where small, composable packages reduce bloat and improve maintainability.snake_case input to camelCase for DTOs/API responses.DB::select() → camelCase arrays).snake_case data but rendering camelCase).require in composer.json with no post-install hooks or complex configurations.composer update).über → uber), may need customization (package likely lacks built-in i18n support).APIKey → apiKey when PascalCase was intended). Mitigate with explicit configuration.snake_case inputs always map to camelCase outputs, or is this context-dependent?HTTPStatusCode as-is)? If not, will a wrapper be needed?Str::camel()/Str::snake() (core since Laravel 5.4). Justify package adoption if adding features like bulk transformations or recursive handling.camel()->toSnake()) or method chaining (e.g., Str::of('foo_bar')->camel())?app()->singleton('caseTransformer', fn() => new CamelCase())).Illuminate\Http\Middleware).getAttribute($key)).JsonResource::toArray()).composer require mattketmo/camel.Str::camel()).UserResource).App\Services\CaseTransformer) for reuse.Str::camel(), phase out the package post-Laravel 10 (when core methods are stable).Str:: method parity).snake_case in DB ↔ camelCase in API).composer update (monitor for breaking changes).Str:: methods; migrate away if the package stagnates.XMLHttpRequest → xMLHttpRequest). Mitigate with:
Log::debug('Transformed', ['input' => $original, 'output' => $transformed])).| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Package abandonment | No updates, potential bugs | Fork or migrate to Laravel’s Str:: methods. |
| Over-aggressive transformations | Data corruption (e.g., ID → iD) |
Add validation layers (e.g., regex checks). |
| Edge case mishandling | Unexpected outputs (e.g., HTTP2 → http2) |
Test with comprehensive edge-case suites. |
| Dependency conflicts | Rare, but possible with Composer | Use composer why-not to detect conflicts. |
CamelCase::snake('fooBar')).XML → xml vs. preserve acronyms).// API Resource
public function toArray($request)
{
return array_map('CamelCase::snake', parent::toArray($request));
}
// Form Request
protected function prepareForValidation()
{
$this->merge([
'user_name' => CamelCase::camel($this->userName),
]);
}
laravel-pint).How can I help you explore Laravel packages today?