Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Sluggable Laravel Package

spatie/laravel-sluggable

Automatically generate unique, URL-friendly slugs for Laravel Eloquent models on save. Configure slug sources and target fields via a simple HasSlug trait and SlugOptions, with built-in uniqueness handling using Laravel’s Str::slug.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • SEO & User Experience: Enables clean, human-readable URLs (e.g., /blog/my-article vs /blog?id=123), improving organic traffic and usability.
  • Content Management Systems (CMS): Core feature for blog posts, articles, or product pages where slugs act as permalinks.
  • Multilingual Support: Integrates with laravel-translatable for locale-specific slugs (e.g., /en/my-article, /nl/mijn-artikel).
  • Route Optimization: Reduces complexity in route definitions by leveraging implicit model binding via slugs.
  • Build vs. Buy: Avoids reinventing slug generation logic, saving dev time while maintaining flexibility.
  • Data Integrity: Prevents duplicate slugs by default, ensuring unique URLs without manual checks.
  • Customization: Supports edge cases like draft states, custom suffixes, or length limits for niche use cases (e.g., short URLs).

When to Consider This Package

  • Avoid if:
    • Your app doesn’t need SEO-friendly URLs (e.g., internal tools, APIs).
    • Slugs are static or managed externally (e.g., pre-defined in a CMS).
    • You’re using a package that already handles slugs (e.g., spatie/laravel-medialibrary for assets).
  • Look elsewhere if:
    • You need real-time slug validation (e.g., during form submission) without DB checks.
    • Your slugs require complex logic (e.g., dynamic suffixes based on business rules).
    • You’re not using Laravel/Eloquent (package is Laravel-specific).
  • Consider alternatives:
    • For bulk slug generation: Use Laravel’s Str::slug() manually in migrations/seeds.
    • For non-SEO slugs: Use UUIDs or auto-increment IDs in routes.

How to Pitch It (Stakeholders)

For Executives: "This package automates the creation of clean, SEO-friendly URLs (e.g., /products/laptop) for our content, reducing bounce rates and improving organic search rankings. It’s a low-code solution that saves development time while ensuring consistency—no more broken links or duplicate URLs. Used by [X] similar platforms, it’s battle-tested and integrates seamlessly with our Laravel stack."

For Engineers: *"Spatie’s laravel-sluggable provides a trait-based, opinionated way to generate slugs for Eloquent models with minimal boilerplate. Key benefits:

  • Zero manual slug management: Auto-generates unique slugs from any field(s) (e.g., title, name).
  • Flexible customization: Supports multi-field slugs, language-specific slugs (via laravel-translatable), and edge cases like draft states.
  • Performance: Uses DB-level uniqueness checks (no N+1 queries).
  • Route-friendly: Works with Laravel’s implicit binding for clean URLs like /posts/{slug}. Example: Add the trait to a Post model, define getSlugOptions(), and boom—slugs are handled automatically. Docs are excellent, and the package is MIT-licensed with active maintenance."*

For Designers/Content Teams: "This tool ensures every piece of content (blog posts, products, etc.) gets a permanent, readable URL like /our-story instead of /page?id=42. No more guessing URLs or dealing with 404s when content is updated. You’ll also get multi-language support if we expand globally."

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport