PHPackages                             tourze/doctrine-indexed-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. [Database &amp; ORM](/categories/database)
4. /
5. tourze/doctrine-indexed-bundle

ActiveLibrary[Database &amp; ORM](/categories/database)

tourze/doctrine-indexed-bundle
==============================

A Symfony bundle that enhances Doctrine ORM with automatic index management using PHP 8 attributes

1.0.4(4mo ago)136.4k20MITPHPCI passing

Since Mar 24Pushed 4mo ago1 watchersCompare

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

READMEChangelog (10)Dependencies (15)Versions (11)Used By (20)

Doctrine Indexed Bundle
=======================

[](#doctrine-indexed-bundle)

[English](README.md) | [中文](README.zh-CN.md)

[![Latest Version](https://camo.githubusercontent.com/db0e16b1a081667d2406a1e13e6dd17fda6f3215a8681572aabdca4b622a125f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f746f75727a652f646f637472696e652d696e64657865642d62756e646c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tourze/doctrine-indexed-bundle)[![Total Downloads](https://camo.githubusercontent.com/5dd972752e060848fe2343c0804193c09b11c8dfb31a0bd96f3bc70683b690d0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f746f75727a652f646f637472696e652d696e64657865642d62756e646c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tourze/doctrine-indexed-bundle)[![PHP Version](https://camo.githubusercontent.com/ee631d1b3535e8b3a99c9152d465e9db0c74b77d6c84694515f8ebc38cda9aea/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253545382e312d626c75653f7374796c653d666c61742d737175617265)](https://www.php.net)[![License](https://camo.githubusercontent.com/2fee234d82bab34dfd2d0ab1c013ced62944cdc7b72fd29a889fdbd80b833779/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f746f75727a652f646f637472696e652d696e64657865642d62756e646c652e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![Build Status](https://camo.githubusercontent.com/687e6b798ace4ddac22e52b7fa7e04c1c98fb078ac11fc0e4a6e7a72060968ba/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f746f75727a652f7061636b616765732f63692e796d6c3f7374796c653d666c61742d737175617265)](https://github.com/tourze/packages)[![Coverage](https://camo.githubusercontent.com/54047ce93215c3614e2139a34742b718a28b253c22a1bdc69ff314c0070d68d2/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f746f75727a652f7061636b616765733f7374796c653d666c61742d737175617265)](https://codecov.io/gh/tourze/packages)

A Symfony bundle that enhances Doctrine ORM with automatic index management.

Features
--------

[](#features)

- Automatically adds indexes to specified entity properties
- Supports regular, fulltext, and unique indexes
- Smart index naming strategy, automatically handles long table names
- Attribute-based configuration (PHP 8 attributes), no extra config files
- Zero configuration required, works out-of-the-box

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

[](#requirements)

- PHP 8.1 or higher
- Symfony 6.4 or higher
- Doctrine Bundle 2.13 or higher

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

[](#installation)

```
composer require tourze/doctrine-indexed-bundle
```

Usage
-----

[](#usage)

1. Register the bundle in `config/bundles.php`:

```
return [
    // ...
    Tourze\DoctrineIndexedBundle\DoctrineIndexedBundle::class => ['all' => true],
];
```

2. Use attributes to mark entity fields that require indexes:

```
use Tourze\DoctrineIndexedBundle\Attribute\IndexColumn;
use Tourze\DoctrineIndexedBundle\Attribute\FulltextColumn;
use Tourze\DoctrineIndexedBundle\Attribute\UniqueColumn;

class YourEntity
{
    #[ORM\Column]
    #[IndexColumn] // Regular index
    private string $name;

    #[ORM\Column(type: 'text')]
    #[FulltextColumn] // Fulltext index
    private string $description;

    #[ORM\Column]
    #[UniqueColumn] // Unique index
    private string $email;
}
```

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

[](#configuration)

This bundle requires no configuration and works out-of-the-box. However, you can customize index names by providing a `name` parameter to the attributes:

```
#[IndexColumn(name: 'custom_index_name')]
private string $field;
```

Index Naming Convention
-----------------------

[](#index-naming-convention)

The bundle automatically generates index names as follows:

- Regular index: `{table_name}_idx_{column_name}`
- Fulltext index: `{table_name}_fulltext_{column_name}`
- Unique constraint: `{table_name}_unique_{column_name}`

If the generated name exceeds the maximum length (64 characters), the bundle will use MD5 hashing to create a shorter name while maintaining uniqueness.

Advanced Usage
--------------

[](#advanced-usage)

### Custom Index Names

[](#custom-index-names)

You can specify custom names for indexes:

```
#[IndexColumn(name: 'search_idx')]
private string $searchable;

#[FulltextColumn(name: 'content_fulltext')]
private string $content;

#[UniqueColumn(name: 'email_unique')]
private string $email;
```

### Multiple Attributes

[](#multiple-attributes)

You can combine different index types on the same entity:

```
class Product
{
    #[ORM\Column]
    #[IndexColumn] // For searching
    #[UniqueColumn] // For uniqueness
    private string $sku;

    #[ORM\Column(type: 'text')]
    #[FulltextColumn] // For full-text search
    #[IndexColumn] // For regular search too
    private string $description;
}
```

How It Works
------------

[](#how-it-works)

- Listens to Doctrine's `loadClassMetadata` event and scans entity properties
- Checks for `IndexColumn`, `FulltextColumn`, or `UniqueColumn` attributes on properties
- Automatically adds the corresponding index to the entity field
- Naming strategy ensures compatibility with DBMS index name length limits

Contributing
------------

[](#contributing)

Feel free to submit issues and pull requests to help improve this bundle.

License
-------

[](#license)

MIT License

###  Health Score

42

—

FairBetter than 90% of packages

Maintenance74

Regular maintenance activity

Popularity24

Limited adoption so far

Community24

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~30 days

Recently: every ~12 days

Total

10

Last Release

144d ago

Major Versions

0.0.5 → 1.0.02025-10-31

### Community

Maintainers

![](https://www.gravatar.com/avatar/e354fdb316da535dfa8ba2e9193a473c403b6bc6fb9170778d1dc50e304c6e9d?d=identicon)[tourze](/maintainers/tourze)

---

Top Contributors

[![tourze](https://avatars.githubusercontent.com/u/13899502?v=4)](https://github.com/tourze "tourze (1 commits)")

---

Tags

doctrinesymfony-bundle

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/tourze-doctrine-indexed-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/tourze-doctrine-indexed-bundle/health.svg)](https://phpackages.com/packages/tourze-doctrine-indexed-bundle)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k16.7M310](/packages/easycorp-easyadmin-bundle)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[contao/core-bundle

Contao Open Source CMS

1231.6M2.4k](/packages/contao-core-bundle)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)

PHPackages © 2026

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