PHPackages                             webfactory/slug-validation-bundle - 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. [Validation &amp; Sanitization](/categories/validation)
4. /
5. webfactory/slug-validation-bundle

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

webfactory/slug-validation-bundle
=================================

Transparent validation of URL slugs in Symfony applications.

1.2.0(4mo ago)612.8k↑71.4%MITPHPPHP &gt;= 8.1CI passing

Since Jul 18Pushed 4mo ago6 watchersCompare

[ Source](https://github.com/webfactory/slug-validation-bundle)[ Packagist](https://packagist.org/packages/webfactory/slug-validation-bundle)[ RSS](/packages/webfactory-slug-validation-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (7)Versions (13)Used By (0)

Slug Validation Bundle
======================

[](#slug-validation-bundle)

[![Tests](https://github.com/webfactory/slug-validation-bundle/workflows/Tests/badge.svg)](https://github.com/webfactory/slug-validation-bundle/workflows/Tests/badge.svg)[![Dependencies](https://github.com/webfactory/slug-validation-bundle/workflows/Dependencies/badge.svg)](https://github.com/webfactory/slug-validation-bundle/workflows/Dependencies/badge.svg)

Do not clutter your controller actions with URL slug validation: This Symfony bundle helps to validate object slugs in URLs transparently.

- Checks if a slug is valid (if provided at all)
- Redirects to the URL with the correct slug on failure (for example after a slug change)

Motivation
----------

[](#motivation)

Handling of URL Slugs is a part of many web applications. Although readable URLs are nice, they usually do not contribute to your main functionality. Instead, slug validation and handling of redirects in case of failure generates a lot of noise in your controller actions, is often cluttered over many parts of the application and makes it harder to see the core problems that are solved.

After facing these problems several times, we decided to create a system that handles slug validation as part of the middleware, that keeps your controller actions clean and lets you concentrate on what is really important: Your domain problems.

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

[](#installation)

Install the bundle via [Composer](https://getcomposer.org):

```
composer require webfactory/slug-validation-bundle

```

Enable the bundle:

```
