- How do I install josezenem/laravel-slugidable in a Laravel application?
- Install it with Composer using composer require josezenem/laravel-slugidable, then check the README for any service provider or config publishing steps. You will typically add a slug column to the target table, add the package trait to your Eloquent model, and wire route model binding. Before adopting, confirm the package Composer constraints match your Laravel and PHP versions.
- How does Laravel Slugidable create slugs from a title and ID?
- The package builds URL-friendly slugs from a model title and its primary key, which helps keep generated values unique. The exact format depends on the configured source field, separator, and length. Review the trait source to confirm the ordering and whether the ID is appended or used only for collision handling.
- How does Laravel Slugidable handle duplicate slugs?
- The package is designed to produce unique slugs and handles duplicates as part of its generation logic. Because the primary key is part of the strategy, collisions are less likely than with title-only slugs. Still test concurrent creates and add a unique database index so duplicates fail safely rather than corrupting routes.
- Can I customize the slug source field, separator, and maximum length?
- Yes, the package advertises customization for the source field, separator, and slug length. Check the README or trait properties for the exact configuration keys and defaults. Test long titles and Unicode input to confirm truncation and transliteration behave as your routes expect.
- Does Laravel Slugidable update a slug when the model title changes?
- The package description says it can handle slug updates when records change, so slug regeneration on updates is likely supported or configurable. Confirm whether it regenerates on every save or only when the source field changes. If public URLs can change, plan redirects and monitor 404s to protect SEO.
- Which Laravel and PHP versions does josezenem/laravel-slugidable support?
- The supported versions are defined in the package composer.json, so check its illuminate and php constraints before installing. The project has low adoption, so verify compatibility on your exact Laravel and PHP combination in staging. Pin the version you validate and review upstream activity before upgrades.
- Does Laravel Slugidable work with UUID or ULID primary keys?
- The title plus ID strategy depends on the primary key being available when the slug is generated. With UUIDs or ULIDs, confirm that your model assigns the key before the slug logic runs, or generate the slug after create. Test this path explicitly because auto-increment IDs and string keys can behave differently in model events.
- Is Laravel Slugidable safe to use in production?
- It can be reasonable for low-risk content models, but the package has low adoption, likely single-maintainer risk, and unknown test depth. Audit the source, pin the version, and keep a fallback slug resolver or in-house trait if URLs are business critical. Treat it as a small dependency you may need to fork.
- How do I backfill slugs for existing records with Laravel Slugidable?
- Add a nullable slug column with a unique index, then backfill in batches using chunkById so large tables do not exhaust memory. Generate slugs deterministically with the same package logic, resolve collisions before enforcing uniqueness, and only then make the column non-nullable. Run the backfill in staging first and keep a redirect plan for URLs that change.
- What are alternatives to Laravel Slugidable for generating slugs?
- Well-known options include spatie/laravel-sluggable and cviebrock/eloquent-sluggable, which have broader adoption and documented feature sets. For simple title plus ID behavior, an in-house trait may be safer and easier to test. Compare maintenance, localization support, and collision handling before choosing.