aesircloud/sluggable
Aesircloud Sluggable is a Laravel package for automatically generating URL-friendly slugs for Eloquent models. It offers configurable source fields, uniqueness handling, and simple integration, helping developers create clean, SEO-friendly routes with minimal setup.
composer require aesircloud/sluggable. Version 1.2.0 adds Laravel 13 support; verify your composer.json platform constraints allow the Laravel version you run, especially if you are upgrading an existing app.php artisan vendor:publish --tag=sluggable-config or the tag documented in the README) and review the defaults before writing code.Post has title, add slug, generate on create, and route to posts by slug.getRouteKeyName(), add that method to the model or resolve records explicitly with the slug column.Schema::table('posts', function (Blueprint $table) {
$table->string('slug')->unique()->after('title');
});
getRouteKeyName() to return the slug column or use explicit binding in routes. Add a fallback lookup by ID or a redirect strategy if legacy URLs must keep working.Post::query()
->whereNull('slug')
->chunkById(500, function ($posts) {
foreach ($posts as $post) {
$post->save(); // or call the package's generation method explicitly
}
});
create() or update() payloads.utf8mb4 has index-length limits. A string('slug') with a unique index may fail on older MySQL configurations; use a sensible maximum length and consider a prefix index only as a last resort.??? or emoji-only strings can produce empty slugs. Configure a fallback (ID, UUID fragment, or a dated string) and test it.php artisan config:cache in production deployments. Stale config can make it appear that package options are ignored.saveQuietly(), observers, and bulk updates may bypass or unexpectedly trigger it. Be explicit about which write paths generate slugs.How can I help you explore Laravel packages today?