PHPackages                             zenstruck/redirect-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. [Utility &amp; Helpers](/categories/utility)
4. /
5. zenstruck/redirect-bundle

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

zenstruck/redirect-bundle
=========================

Store redirects for your site and keeps statistics on redirects and 404 errors

v3.11.0(5mo ago)2665.3k↓60.7%8[2 issues](https://github.com/zenstruck/redirect-bundle/issues)1MITPHPPHP &gt;=8.1CI failing

Since Aug 21Pushed 4mo ago2 watchersCompare

[ Source](https://github.com/zenstruck/redirect-bundle)[ Packagist](https://packagist.org/packages/zenstruck/redirect-bundle)[ Docs](https://github.com/kbond/ZenstruckRedirectBundle)[ GitHub Sponsors](https://github.com/kbond)[ GitHub Sponsors](https://github.com/nikophil)[ RSS](/packages/zenstruck-redirect-bundle/feed)WikiDiscussions 3.x Synced 3d ago

READMEChangelog (10)Dependencies (13)Versions (29)Used By (1)

ZenstruckRedirectBundle
=======================

[](#zenstruckredirectbundle)

[![CI](https://github.com/zenstruck/redirect-bundle/actions/workflows/ci.yml/badge.svg)](https://github.com/zenstruck/redirect-bundle/actions/workflows/ci.yml)[![Latest Version](https://camo.githubusercontent.com/2464125cef5775e4df9902157321c41f4d09f6843f484e78f239e44549831ebd/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7a656e73747275636b2f72656469726563742d62756e646c652e737667)](https://packagist.org/packages/zenstruck/redirect-bundle)[![Total Downloads](https://camo.githubusercontent.com/00dbbc08ff7f7df90a8eee643c2999de30c7a7f1e0cc7932cd196df8b53fbfc5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7a656e73747275636b2f72656469726563742d62756e646c652e737667)](https://packagist.org/packages/zenstruck/redirect-bundle)

This bundle adds entities for redirects and 404 errors.

For redirects, 404 errors are intercepted and the requested path is looked up. If a match is found it redirects to the found redirect's destination. The count and last accessed date are updated as well. A redirect form type and validation is available as well.

404 errors can be logged as well. Each 404 error is it's own record in the database. The path, full URL, timestamp, and referer are stored. Storing each error as a separate record allows viewing statistics over time and seeing all the referer URLs. When a redirect is created or updated, 404 records that match it's path are deleted.

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

[](#installation)

1. Install with composer:

```
composer require zenstruck/redirect-bundle
```

2. Enable the bundle: This Step is only needed if you are not using [Symfony Flex](https://symfony.com/doc/current/setup/flex.html).

    ```
    // config/bundles.php

    return [
            // ...
            Zenstruck\RedirectBundle\ZenstruckRedirectBundle::class => ['all' => true],
        ];
    ```

Configuration
-------------

[](#configuration)

**NOTE:** A `NotFound` or `Redirect` or both must be configured.

### Redirect

[](#redirect)

1. Create your redirect class inheriting the MappedSuperClass this bundle provides:

    ```
    namespace App\Entity;

    use Zenstruck\RedirectBundle\Model\Redirect as BaseRedirect;
    use Doctrine\ORM\Mapping as ORM;

    /**
     * @ORM\Entity
     * @ORM\Table(name="redirects")
     */
    class Redirect extends BaseRedirect
    {
        /**
         * @ORM\Id
         * @ORM\Column(type="integer")
         * @ORM\GeneratedValue(strategy="AUTO")
         */
        private $id;
    }
    ```
2. Set this class in your `zenstruck_redirect.yml`:

    ```
    zenstruck_redirect:
        redirect_class: App\Entity\Redirect
    ```
3. Update your schema (or use a migration):

```
bin/console doctrine:schema:update --force
```

### NotFound

[](#notfound)

1. Create your not found class inheriting the MappedSuperClass this bundle provides:

    ```
    namespace App\Entity;

    use Zenstruck\RedirectBundle\Model\NotFound as BaseNotFound;
    use Doctrine\ORM\Mapping as ORM;

    /**
     * @ORM\Entity
     * @ORM\Table(name="not_founds")
     */
    class NotFound extends BaseNotFound
    {
        /**
         * @ORM\Id
         * @ORM\Column(type="integer")
         * @ORM\GeneratedValue(strategy="AUTO")
         */
        private $id;
    }
    ```
2. Set this class in your `zenstruck_redirect.yml`:

    ```
    zenstruck_redirect:
        not_found_class: App\Entity\NotFound
    ```
3. Update your schema (or use a migration):

```
bin/console doctrine:schema:update --force
```

Form Type
---------

[](#form-type)

This bundle provides a form type (`zenstruck_redirect`) for creating/editing redirects.

```
$redirect = // ...
$form = $this->createForm('zenstruck_redirect', $redirect);
```

You may want to disable the `source` field for already created redirects:

```
// new action
$redirect = new Redirect();
$form = $this->createForm('zenstruck_redirect', $redirect);

// edit action
$redirect = // get from database
$form = $this->createForm('zenstruck_redirect', $redirect, array('disable_source' => true));
```

Full Default Configuration
--------------------------

[](#full-default-configuration)

```
zenstruck_redirect:
    redirect_class:     ~ # Required if not_found_class is not set
    not_found_class:    ~ # Required if redirect_class is not set
    model_manager_name: ~

    # When enabled, when a redirect is updated or created, the NotFound entities with a matching path are removed.
    remove_not_founds: true
```

###  Health Score

58

—

FairBetter than 98% of packages

Maintenance71

Regular maintenance activity

Popularity41

Moderate usage in the ecosystem

Community20

Small or concentrated contributor base

Maturity82

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 94.2% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~180 days

Recently: every ~201 days

Total

28

Last Release

139d ago

Major Versions

1.x-dev → v2.0.02015-06-08

2.x-dev → v3.0.02015-10-23

v3.7.2 → 4.x-dev2023-08-17

PHP version history (6 changes)v3.1.0PHP ^5.6|^7.0

v3.4.0PHP &gt;=7.1.3

v3.5.0PHP &gt;=7.2.5

v3.6.0PHP &gt;=7.4

v3.7.0PHP &gt;=8.0

v3.11.0PHP &gt;=8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/707369cc916e0ea1aacbf077dcba464f611cef879f024d8944311a54a15224b3?d=identicon)[kbond](/maintainers/kbond)

---

Top Contributors

[![kbond](https://avatars.githubusercontent.com/u/127811?v=4)](https://github.com/kbond "kbond (145 commits)")[![napestershine](https://avatars.githubusercontent.com/u/8603325?v=4)](https://github.com/napestershine "napestershine (2 commits)")[![sadikoff](https://avatars.githubusercontent.com/u/213810?v=4)](https://github.com/sadikoff "sadikoff (2 commits)")[![tacman](https://avatars.githubusercontent.com/u/619585?v=4)](https://github.com/tacman "tacman (2 commits)")[![emirii](https://avatars.githubusercontent.com/u/6307976?v=4)](https://github.com/emirii "emirii (1 commits)")[![GwendolenLynch](https://avatars.githubusercontent.com/u/1427081?v=4)](https://github.com/GwendolenLynch "GwendolenLynch (1 commits)")[![Chris53897](https://avatars.githubusercontent.com/u/7104259?v=4)](https://github.com/Chris53897 "Chris53897 (1 commits)")

---

Tags

phpredirectseosymfonysymfony-bundleredirect

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/zenstruck-redirect-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/zenstruck-redirect-bundle/health.svg)](https://phpackages.com/packages/zenstruck-redirect-bundle)
```

###  Alternatives

[rcsofttech/audit-trail-bundle

Enterprise-grade, high-performance Symfony audit trail bundle. Automatically track Doctrine entity changes with split-phase architecture, multiple transports (HTTP, Queue, Doctrine), and sensitive data masking.

1189.8k](/packages/rcsofttech-audit-trail-bundle)[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k17.9M388](/packages/easycorp-easyadmin-bundle)[2lenet/crudit-bundle

The easy like Crud'it Bundle.

1616.4k14](/packages/2lenet-crudit-bundle)[kimai/kimai

Kimai - Time Tracking

4.8k9.0k1](/packages/kimai-kimai)[open-dxp/opendxp

Content &amp; Product Management Framework (CMS/PIM)

9421.6k61](/packages/open-dxp-opendxp)[ahmed-bhs/doctrine-doctor

Runtime analysis tool for Doctrine ORM integrated into Symfony Web Profiler. Unlike static linters, it analyzes actual query execution at runtime to detect performance bottlenecks, security vulnerabilities, and best practice violations during development with real execution context and data.

9410.8k](/packages/ahmed-bhs-doctrine-doctor)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
