mmucklo/inflect
A lightweight PHP inflector for converting English words between singular and plural forms and transforming strings into camelCase, snake_case, humanized, and class-name formats. Useful for ORM table naming, scaffolding, and any app that needs reliable word inflection without heavy dependencies.
composer require mmucklo/inflect
The package is framework-agnostic and requires no service provider, facade, or config file in a Laravel app. It exposes a static-style API (typically Mmucklo\Inflect\Inflect::pluralize() / singularize() / camelize() / tableize() / classify()) that mirrors the Doctrine Inflector contract but memoizes results in a process-local cache. Look at the source src/ first — it is small, and the memoization layer is the only thing that differs from a plain Doctrine Inflector.
The first use case to validate is batching: anywhere you call Str::plural() or an inflector in a loop over the same handful of words (route-name generation, dynamic table/column naming, seeder factories that map many model names). Drop-in the call and confirm identical output to Laravel’s own helpers:
use Mmucklo\Inflect\Inflect;
Inflect::pluralize('category'); // categories
Inflect::tableize('UserProfile'); // user_profiles
If the output matches Str::plural()/Str::snake() for your domain vocabulary, you have a safe starting point; if it diverges, treat the package as an addition, not a replacement.
Memoized batch mapping. Use Inflect when you are classifying or tableizing a fixed set of names repeatedly (e.g. building a lookup of Model => table for a generic repository, or generating route names for all resources in a module registry). The cache pays off on the second and subsequent calls; for a single call per word, Str is equally fast and already loaded.
Wrap it behind your own helper. Because the package is small and low-activity, put it behind a thin class (App\Support\Naming) or an interface so you can swap to Doctrine or Laravel’s Str without touching call sites:
final class Naming
{
public static function table(string $model): string
{
return Inflect::tableize($model);
}
}
Use it in generators and Artisan commands. Custom make:* commands that pluralize/singularize class names, relationship method names, or migration table names benefit most from memoization when they process many entities in one process.
Keep pluralization decisions in one place. Laravel migrations and models should agree on table names. Centralizing through a wrapper means you flip implementations once if you later drop the dependency.
Mix with Str deliberately. It is fine to use Str::plural() for ad-hoc calls and Inflect inside hot loops. Do not scatter both styles across the same domain area; that is where divergent pluralization bites you.
Str replacement. Rule sets differ from Laravel’s. Irregular and compound words (person/people, analysis/analyses, data) can produce different results between Inflect and Str. Test your actual domain vocabulary before swapping.Str::plural’s $count/custom logic.composer.json and keep the wrapper thin so removal is trivial.How can I help you explore Laravel packages today?