PHPackages                             tavvet/tavvet-doctrine-prefix-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. tavvet/tavvet-doctrine-prefix-bundle

ActiveSymfony-bundle[Database &amp; ORM](/categories/database)

tavvet/tavvet-doctrine-prefix-bundle
====================================

Bundle for Symfony 7 and 8 to add a prefix to tables and columns database

v1.4.1(3d ago)16.8k↓91.2%MITPHPPHP ^8.2

Since Jul 27Pushed 2y ago1 watchersCompare

[ Source](https://github.com/tavvet/TavvetDoctrinePrefixBundle)[ Packagist](https://packagist.org/packages/tavvet/tavvet-doctrine-prefix-bundle)[ Docs](https://github.com/tavvet/TavvetDoctrinePrefixBundle)[ RSS](/packages/tavvet-tavvet-doctrine-prefix-bundle/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (8)Versions (11)Used By (0)

TavvetDoctrinePrefixBundle
==========================

[](#tavvetdoctrineprefixbundle)

A Symfony bundle that adds a configurable prefix to Doctrine ORM table and column names, without replacing your naming strategy — it wraps whichever one you already use (`underscore`, `default`, or a custom one) and prefixes its output. Useful when several applications share one database schema and need namespaced tables/columns (e.g. `t_user` / `c_first_name`), or when an existing schema convention requires it.

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

[](#requirements)

- PHP ^8.2 (PHP 8.4+ is required when running on Symfony 8)
- `symfony/framework-bundle` ^7.0 || ^8.0
- `doctrine/orm` ~3.2

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

[](#installation)

```
composer require tavvet/tavvet-doctrine-prefix-bundle
```

If your app doesn't use Symfony Flex to auto-register bundles, add it manually in `config/bundles.php`:

```
return [
    // ...
    Tavvet\DoctrinePrefixBundle\TavvetDoctrinePrefixBundle::class => ['all' => true],
];
```

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

[](#configuration)

Point Doctrine's `naming_strategy` at the service this bundle registers, then configure the prefixes:

```
doctrine:
    orm:
        naming_strategy: tavvet_doctrine_prefix.prefix_naming_strategy

tavvet_doctrine_prefix:
    table_prefix: t_ # default ''
    column_prefix: c__ # default ''
    naming_strategy: # base naming strategy this bundle wraps
        type: doctrine.orm.naming_strategy.underscore # default - 'doctrine.orm.naming_strategy.underscore'
        arguments: [] # constructor arguments for the base naming strategy, default = []
```

KeyTypeDefaultDescription`table_prefix`string`''`Prepended to every table name.`column_prefix`string`''`Prepended to every column name.`naming_strategy.type`string`doctrine.orm.naming_strategy.underscore`Container service id of the base naming strategy to wrap. Must resolve to a real service — `doctrine/doctrine-bundle` registers `doctrine.orm.naming_strategy.default` and `doctrine.orm.naming_strategy.underscore` out of the box; you can also point this at your own service id. Resolved once, at container-compile time — a typo fails fast with a clear `ServiceNotFoundException` instead of breaking silently at runtime.`naming_strategy.arguments`array`[]`Constructor arguments used to build a **new** instance of the resolved class (e.g. `[1]` for `UnderscoreNamingStrategy`'s `CASE_UPPER`). This instance is private to the prefixing strategy — it does not reuse or affect the shared `naming_strategy.type` service elsewhere in the container.How it works
------------

[](#how-it-works)

`PrefixNamingStrategy` implements Doctrine's `NamingStrategy` and delegates every call to the wrapped base strategy, prefixing the result:

```
classToTableName('App\Entity\User')   -> table_prefix . underscore('User')       -> 't_user'
propertyToColumnName('firstName', …)  -> column_prefix . underscore('firstName') -> 'c_first_name'

```

Because the wrapped strategy is built from a **class name**, not a live service, a compiler pass (`ResolveNamingStrategyPass`) resolves `naming_strategy.type` from a service id to its class at container-compile time — this is what lets `naming_strategy.arguments` construct a differently-configured instance than whatever `doctrine-bundle` already wired up for that id.

Caveat: explicit names bypass the prefix
----------------------------------------

[](#caveat-explicit-names-bypass-the-prefix)

Doctrine only consults a naming strategy when a name is **not** given explicitly. So an entity or field with an explicit name is **not** prefixed:

```
#[ORM\Table(name: 'legacy_users')] // stays 'legacy_users', no table_prefix
#[ORM\Column(name: 'raw_email')]   // stays 'raw_email', no column_prefix
```

If you rely on the prefix being applied across the whole schema (e.g. a shared database), avoid hard-coding `name:` on tables and columns and let the naming strategy generate them.

Troubleshooting
---------------

[](#troubleshooting)

### `Symfony LazyGhost is not available` on PHP 8.4

[](#symfony-lazyghost-is-not-available-on-php-84)

On PHP 8.4 with doctrine-bundle 3.x you may hit, when the entity manager boots:

```
Symfony LazyGhost is not available. Please install the "symfony/var-exporter"
package version 6.4 or 7 to use this feature or enable PHP 8.4 native lazy objects.

```

This is a Doctrine / PHP 8.4 concern, not this bundle — on that stack `symfony/var-exporter`resolves to v8, which dropped the LazyGhost helper, so the ORM needs PHP native lazy objects. Enable them in your Doctrine config:

```
doctrine:
    orm:
        enable_native_lazy_objects: true
```

Recent doctrine-bundle recipes may already set this; the option requires doctrine-bundle 3.x and PHP 8.4+.

Development
-----------

[](#development)

Everything runs in Docker, no local PHP toolchain needed.

```
docker compose up -d
docker compose exec php composer install
docker compose exec php vendor/bin/phpunit          # tests (incl. a functional schema-generation test)
docker compose exec php vendor/bin/phpstan analyse  # static analysis (level 9)
docker compose down -v --rmi local                  # tear down: remove container, image and volume
```

Or, as a single ephemeral run that leaves nothing behind:

```
docker compose run --rm php sh -c "composer install && vendor/bin/phpunit && vendor/bin/phpstan analyse"
docker compose down -v --rmi local
```

License
-------

[](#license)

MIT — see [LICENSE](LICENSE).

###  Health Score

46

—

FairBetter than 92% of packages

Maintenance55

Moderate activity, may be stable

Popularity20

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity82

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 81.8% 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 ~403 days

Recently: every ~581 days

Total

10

Last Release

3d ago

Major Versions

v0.1.10 → v1.0.02019-12-25

PHP version history (5 changes)v0.1.7PHP &gt;=5.4.0

v1.0.0PHP ^7.2

v1.1.0PHP ^7.4

v1.2.0PHP ~8.0

v1.4.0PHP ^8.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/19945030?v=4)[Anton Rudakov](/maintainers/tavvet)[@tavvet](https://github.com/tavvet)

---

Top Contributors

[![tavvet](https://avatars.githubusercontent.com/u/19945030?v=4)](https://github.com/tavvet "tavvet (9 commits)")[![brieucthomas](https://avatars.githubusercontent.com/u/3427873?v=4)](https://github.com/brieucthomas "brieucthomas (1 commits)")[![yuddmm](https://avatars.githubusercontent.com/u/58937466?v=4)](https://github.com/yuddmm "yuddmm (1 commits)")

---

Tags

symfonybundledoctrineprefixtablesymfony8columnsymfony7tavvet

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/tavvet-tavvet-doctrine-prefix-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/tavvet-tavvet-doctrine-prefix-bundle/health.svg)](https://phpackages.com/packages/tavvet-tavvet-doctrine-prefix-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)[kimai/kimai

Kimai - Time Tracking

4.8k9.0k1](/packages/kimai-kimai)[2lenet/crudit-bundle

The easy like Crud'it Bundle.

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

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

1.3k1.4M204](/packages/sulu-sulu)[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)[open-dxp/opendxp

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

9421.6k61](/packages/open-dxp-opendxp)

PHPackages © 2026

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