Download the PHP package chamber-orchestra/doctrine-slug-bundle without Composer
On this page you can find all versions of the php package chamber-orchestra/doctrine-slug-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download chamber-orchestra/doctrine-slug-bundle
More information about chamber-orchestra/doctrine-slug-bundle
Files in chamber-orchestra/doctrine-slug-bundle
Package doctrine-slug-bundle
Short Description Symfony bundle for generating unique, URL-friendly slugs for Doctrine ORM entities using PHP 8 attributes
License MIT
Homepage https://github.com/chamber-orchestra/doctrine-slug-bundle
Informations about the package doctrine-slug-bundle
Doctrine Slug Bundle
A Symfony bundle that automatically generates unique, URL-friendly slugs for Doctrine ORM entities using native PHP 8 attributes. Slugs are created on persist and optionally regenerated on update, with built-in collision resolution (hello-world, hello-world-1, hello-world-2, ...).
Features
- Declarative configuration via
#[Slug]PHP attribute - Automatic unique slug generation with collision suffixes
- Optional slug regeneration on entity update
- Configurable separator character and column length
- Reusable
SlugTraitfor common name/slug entity patterns - Mapping validation (unique constraint, nullable consistency, source type checking)
- Integration with
chamber-orchestra/metadata-bundleand Doctrine event listeners
Requirements
- PHP 8.5+
- Symfony 8.0+
- Doctrine ORM 3.6+ / DoctrineBundle 3.2+
chamber-orchestra/metadata-bundle8.0.*
Installation
If Symfony Flex does not auto-register the bundle, add it manually:
Usage
Annotate a property with the #[Slug] attribute. The slug column must be unique.
Attribute Options
| Option | Type | Default | Description |
|---|---|---|---|
source |
string | — | Source property name for slug generation |
update |
bool | false |
Regenerate slug when the source field changes |
separator |
string | - |
Word separator character |
Using the SlugTrait
For entities with a standard name/slug pattern:
The trait provides $name (varchar 127), $slug (varchar 255, unique) with getName(), setName(), and getSlug() accessors.
Mapping Constraints
The bundle validates mappings at metadata load time:
- Slug column must have
unique: true - Source property must exist and be a string type (
string,text, orascii_string) - If source is nullable, slug must also be nullable
- Separator must be exactly one character
Development
License
MIT
All versions of doctrine-slug-bundle with dependencies
chamber-orchestra/metadata-bundle Version 8.0.*
symfony/string Version 8.0.*
symfony/translation-contracts Version ^3.0