This is an example repository intended to show how to migrate from one framework to another using PSR7, PSR15 and PSR17. The approach is to layer each framework on a middleware, using Symfony Runtime component and Laminas Stratigility's Middleware pipeline feature.
- Symfony Runtime component
- PSR17 runtime
- Laminas Stratigility's middleware pipeline to compose different middlewares.
Using the PSR17 runtime we are able to run any PSR17 complaint HTTP Server Request Handler just by returning it in the public/index.php
main function 👉 The class Laminas\Stratigility\MiddlewarePipe
is an implementation of that interface, so we can just instanciate it and register all the middlewares that should be an implementation of the Psr\Http\Server\MiddlewareInterface
from the PSR15 standard. You will find all the implementations in the namespace App\Middleware
.
Install the Symfony CLI first. Instructions 👉 here 👈. Then 👇
php composer.phar install
symfony serve -d
- /symfony -> Served by Symfony version 7 👉
App\Middleware\SymfonyMiddleware
- /laravel -> Served by Laravel version 11 👉
App\Middleware\LaravelMiddleware
- /slim -> Served by Slim version 4 👉
App\Middleware\SlimMiddleware
- /custom-framework -> Served by a middleware that invokes a custom legacy framework 👉
App\Middleware\LegacyMiddleware
- Any URL that does not match any of these will return a 404 from the custom legacy which is the last level in the middleware stack.