jawira/case-converter
Convert strings between 13 naming conventions with jawira/case-converter: camel, Pascal, snake, Ada, macro, kebab, train, Cobol, title, sentence, dot and more. It auto-detects the input format, offers a factory, and supports i18n.
Install the package via Composer:
composer require jawira/case-converter
v3.7.0 requires PHP 8.2+ (see Gotchas). Start by converting simple strings using the CaseConverter class. The most common first use case is normalizing user input or API payloads into snake_case or camelCase for consistent internal handling:
use Jawira\CaseConverter\CaseConverter;
$converter = new CaseConverter();
$camel = $converter->toCamelCase('user_first_name'); // 'userFirstName'
$snake = $converter->toSnakeCase('UserName'); // 'user_name'
$kebab = $converter->toKebabCase('fileNameWithNumbers'); // 'file-name-with-numbers'
Check the README on GitHub or the Packagist page for the full list of supported cases (toAdaCase(), toCobolCase(), toTrainCase(), etc.).
toSnakeCase()) before processing to unify data structures across services.toCamelCase() or toPascalCase() to match PHP property naming standards.toSnakeCase() for database columns, toKebabCase() for URL slugs).toKebabCase() if downstream services require it.CaseConverter in test fixtures to generate predictable variable names or identifiers across multiple conventions.^3.6 instead of upgrading. Check composer.json in the package for the exact constraint.^3.7 or ~3.7 to stay on the current major line. Avoid floating dev-main in production.toSnakeCase('HTTPRequest') → 'http_request'), but irregular inputs like 'APIV2' may produce unexpected splits. Validate edge cases with a quick unit test.toLower() or toUpper() beforehand if you need to pre-normalize.'uuid' → 'UUID' after conversion).~3.7) to avoid surprise requirement changes.How can I help you explore Laravel packages today?