Application

The Application is the heart of your application. It controlshow your application is configured, and what plugins, middleware, consolecommands and routes are included.

You can find your Application class at src/Application.php. By defaultit will be pretty slim and only define a few defaultMiddleware. Applications can define the following hookmethods:

  • bootstrap Used to load configuration files, define constants and other global functions.By default this will include config/bootstrap.php. This is the ideal placeto load Plugins and global event listeners.
  • routes Used to load routes. By default thiswill include config/routes.php.
  • middleware Used to add middleware to your application.
  • console Used to add console commands to yourapplication. By default this will automatically discover shells & commands inyour application and all plugins.

Adding the new HTTP Stack to an Existing Application

Using the Application class and HTTP Middleware in an existing applicationrequires a few changes to your code.

  • First update your webroot/index.php. Copy the file contents from the appskeleton.
  • Create an Application class. See the Using Middleware sectionabove for how to do that. Or copy the example in the app skeleton.
  • Create config/requirements.php if it doesn’t exist and add the contentsfrom the app skeleton.
  • If you are using the CsrfProtectionMiddleware make sure you remove theCsrfComponent from your controllers.
    Once those three steps are complete, you are ready to start re-implementing anyapplication/plugin dispatch filters as HTTP middleware.

If you are running tests you will also need to update yourtests/bootstrap.php by copying the file contents from the app skeleton.