Doctrine 2 - Entities in more than one directory

Asked

Viewed 118 times

2

Good morning guys, I’m starting in Doctrine 2.4 and I’m developing a system where I separate files from the file core of the application, as follows:

/root
   |-- /src
        |-- /App
              |-- /Model
                    |-- **(Entidades da Aplicação)**
        |-- /Core
              |-- /Model
                    |-- **(Entidades do Core)**

In the Doctrine documentation shows the following way to set 1 directory for Entitys:

$config = Setup::createAnnotationMetadataConfiguration(array(__DIR__."/src"), $isDevMode);

But how to set up when I have more than 1 directory that will contain the Entitys of my application, as my example?

1 answer

1


Simple:

Put it like this:

$config = Setup::createAnnotationMetadataConfiguration(array(__DIR__."/src/App/Model/", __DIR__."/src/Core/Model/"), $isDevMode);

As the first parameter of createAnnotationMetadataConfiguration is the type array, then, put the directories that are part of the mapping of your application, see the example of the parameter below:

array(__DIR__."/src/App/Model/", __DIR__."/src/Core/Model/")

References:

  • 1

    Boy, it’s so hard (kkkk)!!! Thank you very much, as soon as you get home I’ll be there and give you feedback!

  • 1

    Harry Potter, I tested the code and it worked. Thank you very much!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.