1

I'm currently learning as I go, building a Symfony 5 application which shares a database with an existing PHP project. My question is regarding adding a prefix to all tables created by doctrine migrations. I've found a couple of references to what I'm looking to do, but I'm struggling with their implementation due to some of the references being a little outdated and the older versions having different directory structures etc.

This link looked to be promising but I'm unsure where this should be added, it says:

You create this file in your library/DoctrineExtensions directory

I can't find any directories similar to it.

Something like this but for symfony 5? How to setup table prefix in symfony2

Also I looked at this but I got an error message when attempting to require it in composer:

Problem 1 - Installation request for borsaco/doctrine-prefix-bundle ^1.0 -> satisfiable by borsaco/doctrine-prefix-bundle[1.0.0]. - borsaco/doctrine-prefix-bundle 1.0.0 requires symfony/framework-bundle ^3.4|^4.0 -> no matching package found.

Any help/pointers would be greatly appreciated

DohMoment
  • 117
  • 2
  • 8
  • The link showing the solution for Symfony 2, that you posted, is your answer already :) Symfony 5 is built on top of Symfony 2, so you should be able to reuse it. Major difference instead of having `MyBundle` you can use `App`. I vote to close as duplicate, but feel free to ask more questions if you encounter problems with it. – dbrumann Feb 25 '20 at 16:17
  • Does this answer your question? [How to setup table prefix in symfony2](https://stackoverflow.com/questions/7504073/how-to-setup-table-prefix-in-symfony2) – dbrumann Feb 25 '20 at 16:17
  • See this class which is build on doctrine https://gist.github.com/KaiCMueller/c6a39c9cf82eb01bc32bb0b7fe57b4fd#file-tableprefixeventlistener-php an here is step by step explanition https://medium.com/@kcmueller/symfony-how-to-add-table-prefixes-with-doctrine-c7feff6ab95 wprks with symfony4 tested. –  Feb 25 '20 at 16:23
  • I followed the guide from @Dlk, had to amend the `getPrefix()` func for my directory layout, after that all's good, thank you both for the help. :) Hopefully this'll help out another newbie in future! If you'd like to answer it with those links, I'll mark this as solved – DohMoment Feb 25 '20 at 17:06
  • You can answer your own question, if not I will do it tomorrow :) –  Feb 25 '20 at 20:08

1 Answers1

0

I followed the guide from @Dlk, had to amend the getPrefix() func for my directory layout, after that all's good, thank you both for the help. :) Hopefully this'll help out another newbie in future!

DohMoment
  • 117
  • 2
  • 8