schranz-templating / templating

A template abstraction prototype for php template engines.
MIT License
23 stars 0 forks source link

Checking for Best Practices in Laminas Module creation #6

Closed alexander-schranz closed 1 year ago

alexander-schranz commented 2 years ago

I'm not yet sure if my Module.php are using best practices.

Also not sure what the best way of addExtension in Latte and Twig is:

Would be nice if somebody of Laminas Core Team could have a look at the existing Module.php definition of Latte: https://github.com/schranz-templating/templating/blob/0.1/src/Integration/Laminas/Latte/Module.php

Was also linked to delegators: https://docs.laminas.dev/laminas-servicemanager/delegators/ but not sure if that can solve extension registry problem as it is more like service registration.

Update: After some discussions the extensions config is fine. For modules there could be two other ways which I got following response:

  • Define a plugin manager for the component. These use SM configuration, and the component then pulls from the plugin manager when it needs an extension.
  • Compose an event manager and trigger an event. In the MVC, modules then attach listeners to that event (or, in Mezzio, you use a PSR-14 dispatcher, and wire in listeners in your listener provider).
alexander-schranz commented 1 year ago

The implementation via configuration is fine and so we will stay with it.