[RFC]: Deprecate ApplicationConfigInjectionDelegator
and Application#post
, etc.
#147
Labels
ApplicationConfigInjectionDelegator
and Application#post
, etc.
#147
RFC
Goal
Provide dedicated delegators for both
Router
andMiddlewarePipe
instead of havingApplicationConfigInjectionDelegator
only.That way, we move configuration of those "services" to the container rather than to the
Application
. This will benefitlaminas-cli
commands which should not be aware that they have to$container->get(Application::class)
before using$container->get(Router::class)
(because the application delegator might register routes).Allowing the
Application#*
methods to configure routes should be dropped at all.Background
There are several issues in
laminas-cli
which are around the fact, that something is being executed in eitherlaminas-mvc
ormezzio
Application (orindex.php
) which is not available in the CLI Commands afterwards.Regarding
mezzio
, thats "okayish" as it never provided such details from the beginning.In
laminas-mvc
that is problematic, as we suggest projects migrating away fromlaminas-console
to uselaminas-cli
.laminas-console
actually usedindex.php
oflaminas-mvc
which inherited exactly the same method as a HTTP request does. Therefore, everything was bootstrapped, etc. the same way as for an HTTP request. That is not the case forlaminas-cli
and thus, there are plenty of complaints about this (and I understand these complaints somehow).Considerations
Migration from
ApplicationConfigInjectionDelegator
Users will have to modify their config:
ApplicationConfigInjectionDelegator
as a delegator forMezzio\Application
RouterConfigInjectionDelegator
as a delegator forMezzio\RouteCollectorInterface
but maybe that should be dropped as well as we so that routes are directly passed to theMezzio\RouterInterface
itself while having deduplication happening in the delegator? Dunno, just sharing ideas hereMiddlewarePipelineConfigInjectionDelegator
as a delegator forMiddlewarePipeInterface
Removal of the
Application#pipe
,Application#get
, etc. methodsWhen it comes to the removal of the handy methods
Application#pipe
, etc., we should encourage users to properly move this to configuration rather than having dedicated php files which are returning callables so that these can be called inindex.php
.Having stuff configured this way won't be available to
laminas-cli
commands, so we are unable to e.g. provide a CLI command inmezzio-router
to list all registered routes as the routes are injected at HTTP request runtime (inindex.php
callingroutes.php
callable) and not at configuration time. Therefore, there is no way of accessing these methods which makes the CLI command kinda useless.Proposal(s)
Instead of having a dedicated delegator which still configures the application and not the Router/Middlewarepipeline, I'd suggest having a dedicated delegator for both Router and Middlewarepipeline.
Regarding the
Application#pipe
, etc. sugar, we should encourage projects to move this into the configuration - we could provide some static factories to provide autocompletion, i.e. something like:This will allow upstream to have the same methods available but using these to create a proper route configuration rather than directly injecting the route.
Appendix
Ref: laminas/laminas-cli#106 (comment)
The text was updated successfully, but these errors were encountered: