Container reset
Performing a reset on the dependency container will return it to its initial state — clearing its internal buffer of properties and dependencies, bringing them back to the same state they were in when the container was first initialized.
Complete reset of the dependency container
The reset() method, which performs a reset of the container, can be called on both a runtime container and a compiled container.
Resetting the container restores its entire configuration to the state it was in at the time of its initial initialization. For all PHP classes and container definitions declared via helper functions or attributes, any internal property buffers and auxiliary caches will also be cleared.
Container parameters are likewise reset.
WARNING
For runtime objects and container runtime parameters defined within the container, internal buffers and caches will also be cleared resetting them to their initial state. If these values are still required after the container has been reset, you will need to re-declare them.
use Kaspi\DiContainer\DiContainerBuilder;
$container = (new DiContainerBuilder())
->import('App\\', '/app/src')
->load('/app/config/container/services.php')
->loadParameters('/app/config/container/parameters.php')
->build();
// ...
$container->reset();