symfony / symfony/maker-bundle

[RFC] Provide db prefix in make:entity

Open
#327 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
3.4k
Forks
427
Avg merge
2d 22h
Merged PRs (30d)
20

Description

Would a PR for a feature to provide a db table name prefix be accepted?

A use case is that a user would like to prefix his tables with a certain prefix. Therefor we could add the @ORM\Table annotation if a prefix is defined. Together with the prefix we could generate the db name based on the namingstrategy setup in the doctrine config.

Some pseudo code for a method in the doctrine helper:

public function getTableName($className)
{
    $em = $this->getRegistry()->getManagerForClass($className);
    if (null === $em) {
        $em = $this->getRegistry()->getManager();
    }
        
    $tableName = $em->getConfiguration()->getNamingStrategy()->classToTableName($className);

    return $tableName;
}

That way we can reliable determin the table name and add the given prefix. If no prefix is defined I would suggest to not add the @Table annotation

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the make:entity command and the Doctrine helper described in the issue, then inspect how Doctrine configuration and naming strategies are accessed. Done should mean a configured table prefix is reflected in generated entities using the configured naming strategy, while no prefix leaves the @Table annotation absent.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
cli, database
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.