LeoFelipe Posted June 3, 2014 Share Posted June 3, 2014 I'm starting in Doctrine 2.4 and I'm developing a system where I separate the core files and application files, as follows: /root |-- /Src |-- /App |-- /Model |-- ** (Application Entities) ** |-- /Core |-- /Model |-- ** (Core Entities) ** In the Doctrine documentation shows the following form to set 1 directory for Esntitys: $config = Setup::createAnnotationMetadataConfiguration(array(__DIR__. "/src"), $isDevMode); But when I have to configure more than one directory that will contain the Entitys of my application, how to proceed? Thanks in advance! Quote Link to comment https://forums.phpfreaks.com/topic/288966-doctrine-configure-entities-in-more-than-one-directory/ Share on other sites More sharing options...
ignace Posted June 3, 2014 Share Posted June 3, 2014 (edited) That is really hard, your mind may be blown. $dirs = array(__DIR__ . "/src", __DIR__ . "/src2"); $config = Setup::createAnnotationMetadataConfiguration($dirs, $isDevMode); To make it easier to consume: $config = Setup::createAnnotationMetadataConfiguration(array(__DIR__ . "/src", __DIR__ . "/src2"), $isDevMode);Now for the complete meltdown: $config = Setup::createConfiguration(); $chain = new MetadataChain(); foreach (array('xml' => __DIR__ . "/src", 'yml' => __DIR__ . "/src2") as $driverName => $path) { switch ($driverName) { case 'xml': $driver = new SimplifiedXmlMetadataDriver($path); case 'yml': $driver = new SimplifiedYamlMetadataDriver($path); } $chain->addDriver($driver); } $config->setMetadataDriver($chain); ..EDIT: do not copy paste, it won't work, you'll need to do your own research. Edited June 3, 2014 by ignace Quote Link to comment https://forums.phpfreaks.com/topic/288966-doctrine-configure-entities-in-more-than-one-directory/#findComment-1481786 Share on other sites More sharing options...
LeoFelipe Posted June 3, 2014 Author Share Posted June 3, 2014 (edited) That is really hard, your mind may be blown. $dirs = array(__DIR__ . "/src", __DIR__ . "/src2"); $config = Setup::createAnnotationMetadataConfiguration($dirs, $isDevMode); To make it easier to consume: $config = Setup::createAnnotationMetadataConfiguration(array(__DIR__ . "/src", __DIR__ . "/src2"), $isDevMode); º_º ... Is that so hard? kkkk I should have known. I'm ashamed of myself! Upon arriving home I will test and give feedback. Thank you very much. Edited June 3, 2014 by LeoFelipe Quote Link to comment https://forums.phpfreaks.com/topic/288966-doctrine-configure-entities-in-more-than-one-directory/#findComment-1481787 Share on other sites More sharing options...
LeoFelipe Posted June 4, 2014 Author Share Posted June 4, 2014 That is really hard, your mind may be blown. $dirs = array(__DIR__ . "/src", __DIR__ . "/src2"); $config = Setup::createAnnotationMetadataConfiguration($dirs, $isDevMode); To make it easier to consume: $config = Setup::createAnnotationMetadataConfiguration(array(__DIR__ . "/src", __DIR__ . "/src2"), $isDevMode);Now for the complete meltdown: $config = Setup::createConfiguration(); $chain = new MetadataChain(); foreach (array('xml' => __DIR__ . "/src", 'yml' => __DIR__ . "/src2") as $driverName => $path) { switch ($driverName) { case 'xml': $driver = new SimplifiedXmlMetadataDriver($path); case 'yml': $driver = new SimplifiedYamlMetadataDriver($path); } $chain->addDriver($driver); } $config->setMetadataDriver($chain); ..EDIT: do not copy paste, it won't work, you'll need to do your own research. Hey man. Thanks again for your help. I tested the code and it worked. Quote Link to comment https://forums.phpfreaks.com/topic/288966-doctrine-configure-entities-in-more-than-one-directory/#findComment-1481869 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.