laminas / laminas-mvc

Laminas's event-driven MVC layer, including MVC Applications, Controllers, and Plugins
https://docs.laminas.dev/laminas-mvc/
BSD 3-Clause "New" or "Revised" License
142 stars 51 forks source link

Implement a application event dispatcher reset #126

Open Jurigag opened 2 years ago

Jurigag commented 2 years ago

Feature Request

So, currently in laminas-test a reset of test is done just by initialization of whole application again which in big codebase can take a huge amount of time, with creating container, reading configs etc.

Most of other frameworks works pretty fine with typical request-response loop, like you can execute multiple request on application itself and it will return proper responses. Tried the same here when using laminas-test while keeping the same application instance - not possible, the second request to same endpoint doesn't go to the controller.

Not sure actually if this is a bug or feature request, but it could be good to somehow clear/reset event dispatcher of application without recreating and bootsraping whole container once again.

Q A
New Feature yes
RFC n/a
BC Break n/a
Ocramius commented 2 years ago

Resetting services is not really feasible, without making individual services resettable via proxies :thinking:

Xerkus commented 2 years ago

At some point me and others in then zend framework community tried to use same application to handle multiple consecutive requests. We doscovered that application was leaking state between requests pretty badly in unpredictable manner.

I do not think application can be reliably reset for testing purposes for much the same reasons it couldn't be used for multiple requests.

Ocramius commented 2 years ago

Biggest issue being that the controller helpers and view helpers are stateful by design too.

Services being resettable is feasible with some work, but that would require expanding the laminas/laminas-servicemanager capabilities substantially.