Middlewares
Apiato middlewares are just Laravel Middlewares, and they function in the exact same way as Laravel middlewares. However, they come with additional rules and conventions specific to Apiato.
To generate new middlewares
you may use the apiato:generate:middleware
interactive command:
php artisan apiato:generate:middleware
Rulesβ
- All container-specific Middlewares:
- MUST be placed in the
app/Containers/{Section}/{Container}/Middlewares
directory. - MUST be registered in their respective container's
App\Containers\{Section}\{Container}\Providers\MiddlewareServiceProvider
class.
- MUST be placed in the
- All general Middlewares:
- MUST be placed in the
app/Ship/Middlewares
directory. - MUST be registered in the
App\Ship\Kernels\HttpKernel
class.
- MUST be placed in the
- All non-Laravel or third-party package Middlewares MUST extend the
App\Ship\Parents\Middlewares\Middleware
class.- The parent extension SHOULD be aliased as
ParentMiddleware
.
- The parent extension SHOULD be aliased as
Folder Structureβ
The highlighted sections showcase middleware registration points:
app
βββ Containers
β βββ Section
β βββ Container
β βββ Middlewares
β β βββ DemoMiddleware.php
β β βββ ...