Skip to content
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

[RFC]: Ship factories, config providers and make use of plugin-installer #121

Open
gsteel opened this issue Jan 14, 2022 · 3 comments
Open
Labels

Comments

@gsteel
Copy link
Member

gsteel commented Jan 14, 2022

RFC

Q A
Proposed Version(s) 3.0.0 possibly 2.x.x
BC Break? Maybe

Goal

#110 - Yet to be merged or approved, adds config providers that help to centralise configuration, removing config from inside HelperPluginManager for example.

It would be useful to provide factories for the key components in view such as the various renderers and plugin managers and expose these config providers (And maybe also Modules for MVC) to the component installer plugin, and also require that plugin in declared dependencies.

The main reason for shipping factories is they provide an opportunity to document in code how these things should be constructed, how they fit together and provide SA tools and consumers concrete examples of what configuration looks like.

Considerations

  • It will become easier to customise how mezzio/mezzio-laminasviewrenderer puts these components together
  • An out-of-the-box working configuration for MVC/Mezzio
  • Provides a clear path to decoration of configured services with delegators without first having to setup a factory
  • Documentation for using config providers without the installer plugin.

Proposal(s)

Depending on whether this is first implemented as feature addition in 2.x, Adding final factories for anything that would benefit:

  • PhpRenderer
  • View
  • Template Resolvers
  • Plugin Managers
  • Rendering Strategies

Additionally, at the same time in a 3.x release or as a separate change, ship factories and add constructors for DI for the many helpers to minimise the amount of "reaching into the view" for hidden dependencies when an Escaper provided to the constructor is all that's really needed. (Also perhaps removing the inheritance tree from helpers where there is no need for it)

@gsteel gsteel added the RFC label Jan 14, 2022
@froschdesign
Copy link
Member

froschdesign commented Jan 14, 2022

@gsteel
Copy link
Member Author

gsteel commented Jan 14, 2022

@froschdesign

I guess for view helpers, the important thing is aliases used with __call, so it would mean duplicating a lot of functionality already present in SM such as detecting cyclic dependencies, resolved instances, auto-invokables, in-memory registry of constructed helpers etc, if compatibility with existing configuration was to be preserved.

But I guess, if all the plugin manager did was receive a list of aliases mapped to something available in a user-supplied container, then the plugin manager could be really straight-forward.

The configuration BC break would be significant because all those custom helper factories would need to be moved to dependencies.factories from view_helpers.factories, but long-term it's much less code to maintain and a hell of a lot easier to reason about. Also, documenting it shouldn't be too much of a headache. I'm in!

@froschdesign
Copy link
Member

…but long-term it's much less code to maintain and a hell of a lot easier to reason about.

That's the idea behind it! 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants