Creating a Middleware

To generate a Middleware, you should use the automated generator provided by Strata. It will validate your object’s name and ensure it is defined following the intended conventions.

Using the command line, run the generate command from your project’s base directory. In this example, we will generate a middleware for IP forwarding:

$ ./strata generate middleware IpForwarding

The command generates a couple of files for you, including the actual Middleware initializer file and test suites for the generated class.

Scaffolding controller ArtistController
  ├── [ OK ] src/Middleware/IpForwardingInitializer.php
  └── [ OK ] test/Middleware/IpForwardingInitializerTest.php