-
Notifications
You must be signed in to change notification settings - Fork 2.5k
[ZF3] Thinking component as module #5524
Comments
With a ServiceRequest, it might be possible to make the PluginManager a factory instead?
|
@Ocramius, in this case ViewHelperPlugin is a ServiceRequest?
|
The thing you're doing with this kind of flow is making all components based on the service locator. I am not sure if that's what we really want. Obviously, plugin managers can already depend on the SM (note, not all do! Some places use the more lightweight So if all components should rely on this pattern, you imply all components are using the SM in some sort of way. We really should consider the consequences this might cause. I am not against this per se (standardisation is a good thing), but we must check the negative impact as well. |
Well... Not exactly. Service manager would indeed be a soft dependency for all components, but as you said, plugin managers ARE service managers, so if they want to use plugin managers, they will have a dependency to SL anyway. |
Some quick thoughts; I ran into a similar issue with https://github.com/zendframework/zf2/blob/master/library/Zend/Mvc/Router/Http/TreeRouteStack.php where it seems as if it would be nicer if all those class mappings were just in the main application configuration of the service manager. It also looks like the AbstractPluginManager is not much more than a factory, which makes things trickier since we'd want to know which factory to use and possibly which class to use (if it is not in the same namespace). Which suggests that it might be easier to specify the factory rather than the actual class, e.g
Which could be simplified further by having a service manager config for the default factory to use unless one has been explicitly set for that plugin/helper. |
For ZF3, what about creating a new component, called Zend\Application, whose task will be to only include a script that will automatically add the component as a module: https://getcomposer.org/doc/articles/scripts.md#defining-scripts Each component will have its own scripts section so that it auto-registrate into the "modules" list. Each Zend component will have a name like "Zend\ServiceManager". This way, we avoid any hack, we make everything consistent, and this will allow to cleanly solve the issue? |
Mmhhh nvm, this only apply to root composer.json, so this will likely does not work. |
The one big issue I see with the proposal to have each component as a module is performance. If we consider every component a module, then by default we have to load:
which leads to a lot of memory and I/O overhead. I'd rather see this stuff defined in the skeleton application, to be honest, as we can then have use-case specific skeletons that selectively provide the configuration. |
Maybe All is a wrong word..
There are a lot of type of dependencies.. IMO ## Required
Integration dependency
Out of date dependency
This is only a superficial analysis but the idea is "what is MVC pattern?"
Authentication, ModuleManager, Validator are a "doping"... |
This issue has been closed as part of the bug migration program as outlined here - http://framework.zend.com/blog/2016-04-11-issue-closures.html |
Hi everyone,
This follows a discussion I had with @Ocramius yesterday.
Currently, the way plugin manager are configured inside the framework is a bit messy to my opinion. Most plugin manager factories are registered in the Mvc namespace (https://github.com/zendframework/zf2/tree/master/library/Zend/Mvc/Service). This introduces a soft dependency to each of those components in the Mvc namespace, and everyone that want to use those factories require the Mvc component.
The idea is to move each of those things to the given components. This make it REALLY easier to discover how plugin managers are constructed. The same apply for view helpers or filters (we already did that).
Now, the second problem is classes like that: https://github.com/zendframework/zf2/blob/master/library/Zend/Form/View/HelperConfig.php
Those are nothing more than view helpers. What would be good would be to allow each component to have a config that would be merged. Not sure about the syntax yet, but for instance, the Form component could have a config like that:
Next, ViewHelperPluginManagerFactory (which will be situated in the Zend\View component, and not in the Zend\Mvc namespace), will do something like that:
The beauty of this is that it will aggregate both ALL the view helpers specified inside the framework and in the ones specified by third-party modules.
What I'd like is to use inside the framework all the best practices we have accumulated in modules.
Now, the Zend\View would also define it's own config:
Drawbacks
If we consider each component as a module, it may have some performance drawbacks. But I think we could have a lighter way to handle ZF3 components.
The text was updated successfully, but these errors were encountered: