Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/adrenalinkin/doctrine-naming-strategy
Doctrine Camel Case naming strategy
https://github.com/adrenalinkin/doctrine-naming-strategy
camel-case doctrine doctrine-naming-strategy doctrine-orm
Last synced: about 2 months ago
JSON representation
Doctrine Camel Case naming strategy
- Host: GitHub
- URL: https://github.com/adrenalinkin/doctrine-naming-strategy
- Owner: adrenalinkin
- License: mit
- Created: 2018-09-10T21:03:53.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-03-24T19:41:03.000Z (9 months ago)
- Last Synced: 2024-04-25T16:03:20.504Z (8 months ago)
- Topics: camel-case, doctrine, doctrine-naming-strategy, doctrine-orm
- Language: PHP
- Homepage:
- Size: 24.4 KB
- Stars: 6
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.RU.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
Doctrine Naming Strategy [![In English](https://img.shields.io/badge/Switch_To-English-green.svg?style=flat-square)](./README.md)
========================[![PHPUnit](https://github.com/adrenalinkin/doctrine-naming-strategy/workflows/UnitTests/badge.svg)](https://github.com/adrenalinkin/doctrine-naming-strategy/actions/workflows/unit-tests.yml)
[![Coverage Status](https://coveralls.io/repos/github/adrenalinkin/doctrine-naming-strategy/badge.svg?branch=master)](https://coveralls.io/github/adrenalinkin/doctrine-naming-strategy?branch=master)
[![Latest Stable Version](https://poser.pugx.org/adrenalinkin/doctrine-naming-strategy/v/stable)](https://packagist.org/packages/adrenalinkin/doctrine-naming-strategy)
[![Total Downloads](https://poser.pugx.org/adrenalinkin/doctrine-naming-strategy/downloads)](https://packagist.org/packages/adrenalinkin/doctrine-naming-strategy)Введение
--------Компонент содержит стратегию именования столбцов, индексов и таблиц в формате `CamelCase`.
Установка
---------Откройте консоль и, перейдя в директорию проекта, выполните следующую команду для загрузки наиболее подходящей
стабильной версии этого компонента:
```bash
composer require adrenalinkin/doctrine-naming-strategy
```
*Эта команда подразумевает что [Composer](https://getcomposer.org) установлен и доступен глобально.*Пример использования
--------------------Для регистрации новой стратегии необходимо воспользоваться инструкцией, описанной в официальной
документации Doctrine [Implementing a NamingStrategy](https://www.doctrine-project.org/projects/doctrine-orm/en/current/reference/namingstrategy.html).```php
setNamingStrategy($namingStrategy);
```Если вы используете `Symfony`, то воспользуйтесь соответствующим разделом документации `DoctrineBundle` -
[Configuration Reference](https://symfony.com/doc/master/bundles/DoctrineBundle/configuration.html).```yaml
# Регистрируем CamelCaseNamingStrategy как сервис
services:
Linkin\Component\DoctrineNamingStrategy\ORM\Mapping\CamelCaseNamingStrategy:
class: Linkin\Component\DoctrineNamingStrategy\ORM\Mapping\CamelCaseNamingStrategydoctrine:
orm:
naming_strategy: Linkin\Component\DoctrineNamingStrategy\ORM\Mapping\CamelCaseNamingStrategy
```Как будет выглядеть SQL?
------------------------Для демонстрации изменений возьмем
[пример ассоциаций сущностей](https://www.doctrine-project.org/projects/doctrine-orm/en/2.12/reference/working-with-associations.html#association-example-entities)
из официальной документации Doctrine### Сравнение DefaultNamingStrategy и CamelCaseNamingStrategy
![Compare](https://user-images.githubusercontent.com/4967813/184545148-8f07cb13-5a84-4470-a84f-6bb70626fee1.png)#### Сырой SQL для разных стратегий
- [DefaultNamingStrategy](./Tests/Functional/Sql/defaultNamingStrategyWithFk.sql)
- [CamelCaseNamingStrategy](./Tests/Functional/Sql/camelCaseNamingStrategyWithFk.sql)Лицензия
--------[![license](https://img.shields.io/badge/License-MIT-green.svg?style=flat-square)](./LICENSE)