Application is the heart of your application. It controls
how your application is configured, and what plugins, middleware, console
commands and routes are included.
You can find your
Application class at src/Application.php. By default
it will be pretty slim and only define a few default
Middleware. Applications can define the following hook
bootstrapUsed to load configuration files, define constants and other global functions. By default this will include config/bootstrap.php. This is the ideal place to load Plugins and global event listeners.
routesUsed to load routes. By default this will include config/routes.php.
middlewareUsed to add middleware to your application.
consoleUsed to add console commands to your application. By default this will automatically discover shells & commands in your application and all plugins.
Using the Application class and HTTP Middleware in an existing application requires a few changes to your code.
Applicationclass. See the Using Middleware section above for how to do that. Or copy the example in the app skeleton.
_cake_routes_cache definition to config/app.php, if it is not already there.
_cake_routes_cache in development mode
CsrfProtectionMiddlewaremake sure you remove the
CsrfComponentfrom your controllers.
Once those steps are complete you are ready to start re-implementing any application/plugin dispatch filters as HTTP middleware.
If you are running tests you will also need to update your tests/bootstrap.php by copying the file contents from the app skeleton.