italofantone/slugable
Slugable is a Laravel package that automatically generates unique, customizable slugs for Eloquent models. Define the source field, separator, and update behavior to get clean, SEO-friendly URLs with minimal configuration.
This release is a refactor of the slug generation internals rather than a feature drop, so the surface API should look familiar if you have used the package before. Start by confirming the public entry point in the package README — typically a facade/helper (e.g. Str::slug() style global helper or a Slug facade) plus a model trait or observer for automatic slug assignment on save.
Minimal setup:
composer require the package (already done if upgrading) and check composer show <vendor>/<package> to confirm you are on 2.1.0.php artisan vendor:publish --tag=...) and diff it against your existing published copy — a refactor of slug logic often adds or renames options such as separator, max length, uniqueness suffix strategy, or transliteration source.First use case: take one existing model with a slug column, generate a slug for a title containing accents, mixed case, and punctuation, and compare the output with what your current production data looks like. This immediately tells you whether the refactor changed behaviour for your inputs.
Manual generation in a form request or action. Generate the slug explicitly when you need control over the source field, then persist it:
$slug = $slugs->generate($request->input('title'));
$post = Post::create([...$request->validated(), 'slug' => $slug]);
Keep the slug generation in a single service/action rather than scattering calls across controllers — a refactor like this one is much easier to absorb when there is one call site per concept.
Model-level automation. If the package provides a trait/observer for auto-slugging, wire it up behind a saving hook and make it idempotent: only regenerate when the source attribute is dirty, or when the slug is empty. This avoids surprise slug churn on unrelated updates — important after a refactor, since uniqueness handling may now append suffixes differently.
Uniqueness and collision handling. Treat uniqueness as a database concern as well as a package concern: keep a unique index on the slug column, and wrap creation in a retry or firstOrCreate-style loop. If the refactor changed the suffix format (-1, -2 versus timestamp or random suffix), existing rows will not collide with new ones, but your tests asserting exact slug strings will.
Backfills and migrations. For existing data, do not bulk-regenerate slugs silently. Write a one-off command that computes the new slug, logs diffs, and only updates rows where the slug is empty or explicitly flagged. Preserve old slugs in a redirects table if URLs are public.
Testing pattern. Add a data-provider test with the exact inputs you care about — accented characters, CJK, emoji, very long titles, all-punctuation titles, duplicate titles — and assert the generated value. This is your cheapest guard against future refactors.
php artisan config:cache, stale published config can mask new defaults. Clear config and opcache after upgrading.varchar(255) boundary.How can I help you explore Laravel packages today?