PHPackages                             fbeen/uniqueslugbundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. fbeen/uniqueslugbundle

ActiveSymfony-bundle[Utility &amp; Helpers](/categories/utility)

fbeen/uniqueslugbundle
======================

Add easy and quickly unique slugs to your enities and routes

V2.2(6y ago)43.6k4[8 issues](https://github.com/fbeen/uniqueslugbundle/issues)MITPHPPHP ^7.0.8

Since Oct 20Pushed 4y ago1 watchersCompare

[ Source](https://github.com/fbeen/uniqueslugbundle)[ Packagist](https://packagist.org/packages/fbeen/uniqueslugbundle)[ Docs](https://github.com/Fbeen/UniqueSlugBundle)[ RSS](/packages/fbeen-uniqueslugbundle/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (5)Dependencies (10)Versions (6)Used By (0)

FbeenUniqueSlugBundle for Symfony 4
===================================

[](#fbeenuniqueslugbundle-for-symfony-4)

With this bundle you will be able to automatic generate unique slugs inside your entities by simply add a @Slug annotation to a specified field.

### Features include:

[](#features-include)

- very simple installation
- generate unique slugs from **one or more properties** or a **custom method** in an entity
- automatic storage into the database with always a unique slug
- making the slug unique by adding digits when necessary
- add or regenerate slugs in existing tables with the command prompt
- support for date, time and datetime fields with custom format
- supports custom (language specific) slugifiers

Requirements
------------

[](#requirements)

This bundles current release requires Symfony 4. You can use Version 1.2 from this Bundle to use it with Symfony &gt;= 2.7

Known restrictions
------------------

[](#known-restrictions)

- The slugs will be generated when you persist your entity to the database which means that when you create your entity or update properties the slug is not yet available or updatet.
- Slugs cannot made from the entities primary parameter (@Id) because those values will be set by the database INSERT command.
- The slugs will be truncated to the length of the slug field minus 8(\*) characters! the last positions are used for additional digits that will make the slug unique if necessary.

(\*) 8 at default conifguration or otherwise as much as the '**fbeen\_unique\_slug.maximum\_digits**' parameter (see below at "Full configuration example")

Installation
------------

[](#installation)

### 1. Run composer:

[](#1-run-composer)

```
    $ composer require fbeen/uniqueslugbundle

```

### 2. Adding Slug behavior to your entity:

[](#2-adding-slug-behavior-to-your-entity)

Suppose that you have a **Newsitem** entity to display some news on your website and that you want to generate slugs from the **$title** property.

```
    $ bin/console make:slug Newsitem title

```

You might then have an entity like this:

```
