Upgrade Guide
From v1.x to v2.0
v2.0 is a feature release and is backward compatible with v1.x. For the vast majority of applications, upgrading requires no code changes — just update the dependency:
bash
composer require oliwol/laravel-slugify:^2.0Your existing models, attributes, traits and slugs continue to work unchanged. Everything new in v2.0 is opt-in.
Requirements
These are unchanged from late v1.x:
- PHP 8.4+ (required since v1.0.0)
- Laravel 11, 12, or 13 (Laravel 13 support was added; 11 and 12 remain supported)
If your app already runs on a supported v1.x release, it already meets the v2.0 requirements.
What's new (all opt-in)
| Feature | Summary |
|---|---|
SlugConfig fluent API | A slugConfig() method as an alternative to #[Slugify], for closures and conditional logic the attribute can't express |
ID-anchored slugs (appendId) | #[Slugify(appendId: true)] route keys become {slug}-{id} with 308 canonical redirects |
| Laravel Boost skill | Bundled slugify-development skill, auto-discovered by Boost |
None of these change the behavior of existing models — adopt them only if you want them.
Things to be aware of
These are not breaking changes, but worth knowing if you have customized the trait:
getAttributeToCreateSlugFrom()return type widened fromstring|arraytostring|array|Closure. If you override this method on your model with a: string|arrayreturn type, that stays valid (a narrower return type is allowed). The closure case only ever occurs when you opt into aslugConfig()closure source.- New trait methods
getRouteKey()andresolveRouteBindingQuery(). The trait now defines these. For models withoutappendId, they return exactly what Eloquent returned before, so behavior is unchanged. If your model already overrides either method, your class-level override still takes precedence over the trait. - New config key
id_anchored_redirect_status(default308). Only relevant if you useappendId. If you publishedconfig/slugify.phpunder v1, the missing key falls back to the default automatically — re-publishing is optional (see below).
Migration checklist
- Update the dependencybash
composer require oliwol/laravel-slugify:^2.0 - Run your test suite. No changes are expected for existing models.
- (Optional) Refresh the published config if you want the new
id_anchored_redirect_statuskey visible inconfig/slugify.php:bashThis is only needed if you usephp artisan vendor:publish --tag=slugify-config --forceappendIdand want to change its redirect status; otherwise the default applies. - (Optional) Adopt new features —
SlugConfig,appendId, or the Boost skill, as needed.
Migrating from Spatie?
If you are coming from spatie/laravel-sluggable (v3 or v4) rather than from v1.x of this package, see the Migrating from Spatie guide instead.