-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Module support #4
Conversation
Ping @juriansluiman |
Awesome thanks! I guess I will remove the current files, they won't be needed (and I'll release a new version anyway). |
Integration to ZF2 using an abstract factory
Urgh, this was WIP =\ |
Ha :) Was there anything not good? I checked the documentation (and have to admit I just finally got how abstract factories fit in the service manager) and it seems good? I wanted to try to add some tests. |
@mnapoli the idea is that any service not defined by ZF2 explicitly goes back to the abstract factory. I wrote all this on top of my head, so it may not work, but it's fairly simple. |
it falls back to the abstract factory is that what you mean? I'll work on some tests, that will help me learn about ZF's service manager too |
correct As for the tests, you can start from https://github.com/doctrine/DoctrineORMModule/blob/31a0a0aefd424ca2eaecc0303c4bb0d959b1f2c0/tests/Bootstrap.php |
LOL Yeah, this looks WIP and there might be some things to clear out. Just looking at the code, this should work fine. A couple of other things though:
|
Totally agree
Hmm, I don't see a closure? But yes,
You can beat me to death, I will never like this convention of ZF2 :P |
The docs, third code block :)
At least you're on par the Module.php at the root is the convention ;) |
Ah, yes, these definition should come from the module, not be up to the user
I don't like conventions :P |
Sorry guys for having closed this too fast, I was too enthusiastic ;) So I cleaned up the controllers, added some tests (yay now I have a better understanding of how ZF2 works) and updated the documentation. Thx for the link @Ocramius btw, it was very useful to get started. Let me know if the documentation is correct, especially the configuration the user should add: // ...
'modules' => array(
'DI\ZendFramework2',
),
// ...
'service_manager' => array(
// ...
'factories' => array(
'DI\Container' => function () {
$builder = new DI\ContainerBuilder();
// Configure your container here
return $builder->build();
},
),
),
It is the user that will configure his PHP-DI container though? The module provided by this package can't know what kind of configuration the user will want? |
@mnapoli in theory, that closure using the Configuration can be fetched via Consider also that the closure should be moved to a factory class |
The idea is simple:
composer require "mnapoli/php-di-zf2:1.0.*"
DI\ZendFramework2\Module
toapplication.config.php
undermodules