Doctrine 2 module is tight to MVC?

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Doctrine 2 module is tight to MVC?

Deserved
Hello,
Is there a way to use Doctrine 2 Module without MVC? Lets say I have ModuleManager and listeners to configure ServiceManager and add configurations, and I need to load Doctrine 2 and start to use it e.g:

$mm->loadModules();
$em = $sm->get("doctrine.entitymanager.orm_default")

Thank you.
Reply | Threaded
Open this post in threaded view
|

Re: Doctrine 2 module is tight to MVC?

Marco Pivetta
You can use the ModuleManager standalone:

        $serviceManager = new Zend\ServiceManager\ServiceManager(new Zend\Mvc\Service\ServiceManagerConfig(array()));
        $serviceManager->setService('ApplicationConfig', $configuration);
        $serviceManager->get('ModuleManager')->loadModules();
        $serviceManager->get('Application')->bootstrap(); // optional, but recommended.

        $entityManager = $serviceManager->get('Doctrine\ORM\EntityManager');




On 27 February 2013 13:40, Deserved [via Zend Framework Community] <[hidden email]> wrote:
Hello,
Is there a way to use Doctrine 2 Module without MVC? Lets say I have ModuleManager and listeners to configure ServiceManager and add configurations, and I need to load Doctrine 2 and start to use it e.g:

$mm->loadModules();
$em = $sm->get("doctrine.entitymanager.orm_default")

Thank you.


If you reply to this email, your message will be added to the discussion below:
http://zend-framework-community.634137.n4.nabble.com/Doctrine-2-module-is-tight-to-MVC-tp4659346.html
To start a new topic under Zend Framework, email [hidden email]
To unsubscribe from Zend Framework Community, click here.
NAML

Reply | Threaded
Open this post in threaded view
|

Re: Doctrine 2 module is tight to MVC?

Deserved
Marco Thank You for your instant reply, your solution works but it has to many things that I am not gonna need. Anyway it helped me to identify what exactly I am missing. It was 'Configuration' Service, that is looks like eventually a pointer to ListenerOption, and 'Config' that is alias to 'Configuration' and it works aswell :)
Reply | Threaded
Open this post in threaded view
|

Re: Doctrine 2 module is tight to MVC?

Marco Pivetta
The ORM module expects an MVC-ish setup, so that's the correct way of instantiating everything. That's also the way I setup functional tests in my test environment (see https://gist.github.com/Ocramius/3994325 )



On 27 February 2013 15:51, Deserved [via Zend Framework Community] <[hidden email]> wrote:
Marco Thank You for your instant reply, your solution works but it has to many things that I am not gonna need. Anyway it helped me to identify what exactly I am missing. It was 'Configuration' Service, that is looks like eventually a pointer to ListenerOption, and 'Config' that is alias to 'Configuration' and it works aswell :)


If you reply to this email, your message will be added to the discussion below:
http://zend-framework-community.634137.n4.nabble.com/Doctrine-2-module-is-tight-to-MVC-tp4659346p4659352.html
To start a new topic under Zend Framework, email [hidden email]
To unsubscribe from Zend Framework Community, click here.
NAML

Reply | Threaded
Open this post in threaded view
|

Re: Doctrine 2 module is tight to MVC?

Deserved
Ye I see, but would not it be better if Doctrine* modules would be dependable only on ModuleManger/ServiceProvicer but without MVC? As of me, I setup this way, for now it looks like it works:


$listener = new ListenerOptions();
$moduleManager = new ModuleManager();
$serviceManager = new ServiceManager();

/**
 * Includes ConfigListener, ModuleAutoloader, AutoloaderListener, ModuleResolverListener
 * and others are my own need listeners.
 */
$moduleManager->getEventManager()->attachAggregate(new MyOwnAggregator());

$serviceManager->setService('Configuration', $moduleManager->getEvent()->getConfigListener()->getMergedConfig(false));
$serviceManager->setAlias('Config', 'Configuration');

$moduleManager->getModule('DoctrineModule')->init($moduleManager);
$moduleManager->getModule('DoctrineORMModule')->init($moduleManager);

$serviceManager->get('Doctrine\ORM\EntityManager')


Marco Pivetta wrote
The ORM module expects an MVC-ish setup, so that's the correct way of
instantiating everything. That's also the way I setup functional tests in
my test environment (see https://gist.github.com/Ocramius/3994325 )

Marco Pivetta

http://twitter.com/Ocramius

http://ocramius.github.com/


On 27 February 2013 15:51, Deserved [via Zend Framework Community] <
[hidden email]> wrote:

> Marco Thank You for your instant reply, your solution works but it has to
> many things that I am not gonna need. Anyway it helped me to identify what
> exactly I am missing. It was 'Configuration' Service, that is looks like
> eventually a pointer to ListenerOption, and 'Config' that is alias to
> 'Configuration' and it works aswell :)
>
> ------------------------------
>  If you reply to this email, your message will be added to the discussion
> below:
>
> http://zend-framework-community.634137.n4.nabble.com/Doctrine-2-module-is-tight-to-MVC-tp4659346p4659352.html
>  To start a new topic under Zend Framework, email
> [hidden email]
> To unsubscribe from Zend Framework Community, click here<http://zend-framework-community.634137.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=634137&code=b2NyYW1pdXNAZ21haWwuY29tfDYzNDEzN3wxNzE0OTI1MTk4>
> .
> NAML<http://zend-framework-community.634137.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>
Reply | Threaded
Open this post in threaded view
|

Re: Doctrine 2 module is tight to MVC?

Marco Pivetta
The only MVC bit in my example is `Zend\Mvc\Service\ServiceManagerConfig`, and it makes things so simple that it's not even worth discussing it in my opinion.

Yes, you can use DoctrineORMModule also without that by the way :)



On 28 February 2013 08:52, Deserved [via Zend Framework Community] <[hidden email]> wrote:
Ye I see, but would not it be better if Doctrine* modules would be dependable only on ModuleManger/ServiceProvicer but without MVC? As of me, I setup this way, for now it looks like it works:


$listener = new ListenerOptions();
$moduleManager = new ModuleManager();
$serviceManager = new ServiceManager();

/**
 * Includes ConfigListener, ModuleAutoloader, AutoloaderListener, ModuleResolverListener
 * and others are my own need listeners.
 */
$moduleManager->getEventManager()->attachAggregate(new MyOwnAggregator());

$serviceManager->setService('Configuration', $moduleManager->getEvent()->getConfigListener()->getMergedConfig(false));
$serviceManager->setAlias('Config', 'Configuration');

$moduleManager->getModule('DoctrineModule')->init($moduleManager);
$moduleManager->getModule('DoctrineORMModule')->init($moduleManager);

$serviceManager->get('Doctrine\ORM\EntityManager')


Marco Pivetta wrote
The ORM module expects an MVC-ish setup, so that's the correct way of
instantiating everything. That's also the way I setup functional tests in
my test environment (see https://gist.github.com/Ocramius/3994325 )

Marco Pivetta

http://twitter.com/Ocramius

http://ocramius.github.com/


On 27 February 2013 15:51, Deserved [via Zend Framework Community] <
[hidden email]> wrote:

> Marco Thank You for your instant reply, your solution works but it has to
> many things that I am not gonna need. Anyway it helped me to identify what
> exactly I am missing. It was 'Configuration' Service, that is looks like
> eventually a pointer to ListenerOption, and 'Config' that is alias to
> 'Configuration' and it works aswell :)
>
> ------------------------------
>  If you reply to this email, your message will be added to the discussion
> below:
>
> http://zend-framework-community.634137.n4.nabble.com/Doctrine-2-module-is-tight-to-MVC-tp4659346p4659352.html
>  To start a new topic under Zend Framework, email
> [hidden email]



If you reply to this email, your message will be added to the discussion below:
http://zend-framework-community.634137.n4.nabble.com/Doctrine-2-module-is-tight-to-MVC-tp4659346p4659356.html
To start a new topic under Zend Framework, email [hidden email]
To unsubscribe from Zend Framework Community, click here.
NAML

Reply | Threaded
Open this post in threaded view
|

Re: Doctrine 2 module is tight to MVC?

Deserved
You are the boss :) In my opinion ZF2 is modular/component based framework and have module that forces you to load MvC like SM is not just nice, as do I really all the features that it brings? Maybe I do not want SM at all? :D It just small nice to have things, module, that needs only Autloader and Configuration :)

Reply | Threaded
Open this post in threaded view
|

Re: Doctrine 2 module is tight to MVC?

Marco Pivetta
I agree on that. If you can inspect what dependencies we need on DoctrineORMModule, DoctrineMongoODMModule and DoctrineModule (excluding zendframework/zend-mvc) I'll be glad to merge a pull request :)



On 28 February 2013 11:50, Deserved [via Zend Framework Community] <[hidden email]> wrote:
You are the boss :) In my opinion ZF2 is modular/component based framework and have module that forces you to load MvC like SM is not just nice, as do I really all the features that it brings? Maybe I do not want SM at all? :D It just small nice to have things, module, that needs only Autloader and Configuration :)




If you reply to this email, your message will be added to the discussion below:
http://zend-framework-community.634137.n4.nabble.com/Doctrine-2-module-is-tight-to-MVC-tp4659346p4659358.html
To start a new topic under Zend Framework, email [hidden email]
To unsubscribe from Zend Framework Community, click here.
NAML

Reply | Threaded
Open this post in threaded view
|

Re: Doctrine 2 module is tight to MVC?

Deserved
Will put to my TODO list :)