PHPackages                             runopencode/doctrine-naming-strategy-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. runopencode/doctrine-naming-strategy-bundle

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

runopencode/doctrine-naming-strategy-bundle
===========================================

Set of useful Doctrine2 naming strategies for larger projects that allows you to add prefixes to Entity table names in batch.

3.0.0(6y ago)6807↓100%4[1 PRs](https://github.com/RunOpenCode/doctrine-naming-strategy-bundle/pulls)MITPHPPHP ^7.4

Since Nov 28Pushed 3y ago3 watchersCompare

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

READMEChangelogDependencies (9)Versions (17)Used By (0)

Doctrine naming strategy bundle
===============================

[](#doctrine-naming-strategy-bundle)

[![Packagist](https://camo.githubusercontent.com/2886af81ace62439abdc6b5b988c69a5ee1e963f79009520161699142fb46ecd/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f52756e4f70656e436f64652f646f637472696e652d6e616d696e672d73747261746567792d62756e646c652e737667)](https://packagist.org/packages/runopencode/doctrine-naming-strategy-bundle)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/3dd261d2d56d9fea3d47d4a41b43f5acea4f7a5463aab5089b69136d72dcb523/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f52756e4f70656e436f64652f646f637472696e652d6e616d696e672d73747261746567792d62756e646c652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/RunOpenCode/doctrine-naming-strategy-bundle/?branch=master)[![Build Status](https://camo.githubusercontent.com/79ab352a360447d2fda2932dc269dce754b2b29ae57ddfe038d522c98cedebe0/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f52756e4f70656e436f64652f646f637472696e652d6e616d696e672d73747261746567792d62756e646c652f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/RunOpenCode/doctrine-naming-strategy-bundle/build-status/master)[![Code Coverage](https://camo.githubusercontent.com/26d93ebc4a85f55b92f0066074f223452893387fb7f03c05d4bc97a02f7a19a7/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f52756e4f70656e436f64652f646f637472696e652d6e616d696e672d73747261746567792d62756e646c652f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/RunOpenCode/doctrine-naming-strategy-bundle/?branch=master)[![Build Status](https://camo.githubusercontent.com/0360ad191a15aa89eaf1bb166d3d02540d96759f311ce69f66ec742739201caf/68747470733a2f2f7472617669732d63692e6f72672f52756e4f70656e436f64652f646f637472696e652d6e616d696e672d73747261746567792d62756e646c652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/RunOpenCode/doctrine-naming-strategy-bundle)

[![SensioLabsInsight](https://camo.githubusercontent.com/9069225b67cce54d2a03a40f8afae74b187b3304641d1d5119ea865e04d31a49/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f66366335386434352d323339302d343534302d393930392d6335666236366564316236322f6269672e706e67)](https://insight.sensiolabs.com/projects/f6c58d45-2390-4540-9909-c5fb66ed1b62)

Default Symfony2 Doctrine naming strategy `doctrine.orm.naming_strategy.underscore` for Entity tables is really great and we usually use it without any modifications. However, generated table names sometimes can be too ambiguous and conflicting, especially if vendor bundles are used, or there is a possibility to reuse some of the code from previous projects.

Common practice is, as always, to take over the control of setting names for Entity tables explicitly.

**However, this can be really painful for lazy developers.**

Modifying naming strategy to the rescue
---------------------------------------

[](#modifying-naming-strategy-to-the-rescue)

In Doctrine2, it is quite possible with ease to take over the control of the naming strategy (for details see this Doctrine ["Implementing a NamingStrategy"](http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/namingstrategy.html)) article), while Symfony2 in process of construction of Doctrine service, fetch naming strategy implementation as a service (see this [Stackowerflow question and answer](http://stackoverflow.com/questions/12702657/how-to-configure-naming-strategy-in-doctrine-2)).

In that matter, the purpose of this bundle is to provide you with additional naming strategies which would allow you to keep good quality naming convention for your Entity tables, prevent table name conflicts and still be lazy about it.

Naming strategies within the bundle
-----------------------------------

[](#naming-strategies-within-the-bundle)

Provided naming strategies within the bundles are:

- `runopencode.doctrine.orm.naming_strategy.underscored_bundle_prefix`: Extension of default, underscored, naming strategy, which will add a bundle name prefix to the generated table names (without "bundle" in prefix).
- `runopencode.doctrine.orm.naming_strategy.underscored_class_namespace_prefix`: Extension of default, underscored, naming strategy, which will add a configured prefix to the generated table names of the Entities based on its namespace.
- `runopencode.doctrine.orm.naming_strategy.underscored_namer_collection`: Underscored namer collection is collection of several naming strategies, and one default naming strategy. Default naming strategy will define default name, and then others namers are consulted. First namer in collection that provides different name from default one finally determines name. This will allow you to mix naming strategies, and in conjunction with white and black lists of provided namers you can fine tune naming process of your tables in batch.

Installing the bundle
---------------------

[](#installing-the-bundle)

You can install this bundle by using composer:

```
php composer require "runopencode/doctrine-naming-strategy-bundle"

```

or you can add bundle name to your `composer.json` and execute `php composer update` command.

After that, all you need is to add the bundle to your `config/bundles.php` file:

```
