Implementing a NamingStrategy ============================== .. versionadded:: 2.3 Using a naming strategy you can provide rules for generating database identifiers, column or table names. This feature helps reduce the verbosity of the mapping document, eliminating repetitive noise (eg: ``TABLE_``). .. warning The naming strategy is always overridden by entity mapping such as the `Table` annotation. Configuring a naming strategy ----------------------------- The default strategy used by Doctrine is quite minimal. By default the ``Doctrine\ORM\Mapping\DefaultNamingStrategy`` uses the simple class name and the attribute names to generate tables and columns. You can specify a different strategy by calling ``Doctrine\ORM\Configuration#setNamingStrategy()``: .. code-block:: php setNamingStrategy($namingStrategy); Underscore naming strategy --------------------------- ``\Doctrine\ORM\Mapping\UnderscoreNamingStrategy`` is a built-in strategy. .. code-block:: php setNamingStrategy($namingStrategy); For SomeEntityName the strategy will generate the table SOME_ENTITY_NAME with the ``CASE_UPPER`` option, or some_entity_name with the ``CASE_LOWER`` option. Naming strategy interface ------------------------- The interface ``Doctrine\ORM\Mapping\NamingStrategy`` allows you to specify a naming strategy for database tables and columns. .. code-block:: php referenceColumnName(); } public function joinTableName($sourceEntity, $targetEntity, $propertyName = null) { return strtolower($this->classToTableName($sourceEntity) . '_' . $this->classToTableName($targetEntity)); } public function joinKeyColumnName($entityName, $referencedColumnName = null) { return strtolower($this->classToTableName($entityName) . '_' . ($referencedColumnName ?: $this->referenceColumnName())); } }