Every time UserFrosting is booted up to handle a request, it goes through its application lifecycle. This process includes loading the resources and services in your Sprinkles, setting up the Slim application, registering middleware, and setting up your routes.
At each stage in this process, some events are triggered that you can hook into via an Listener class in your Sprinkle. The overall lifecycle is managed in the UserFrosting Framework and proceeds as follows:
AppInitiatedEvent
or BakeryInitiatedEvent
.run
method on the Slim or Console application.AppInitiatedEvent
is fired. When using the Bakery CLI, the Slim App and associated event is not used. Instead, the Symfony Console application is created, and BakeryInitiatedEvent
is fired. Both the App and Console can still be accessed trough Dependency Injection, which will handle injecting the routes or command as needed.