PSR-15 Pipeline
Global middleware run outermost first and are resolved from the container only when a request reaches them. Class names, middleware objects and callables can be mixed.
Wires your container, middleware and routes into one request handler, with routing by Solo Router 4.
Solo Application 4.0.1 requires PHP 8.3 or later. It creates the RouteCollector, calls your routes.php and builds the router with Solo Router 4, keeps it in a route cache if you ask it to, and throws routing errors instead of answering them with empty responses. Upgrading from 3.x? Read the upgrade guide.
4.0.0, published on 17 October 2026, is an earlier state of this release that still takes the router from the container: install 4.0.1 or later.
<?php
// public/index.php
use App\Providers\HttpServiceProvider;
use Solo\Application\Application;
use Solo\Application\Config;
use Solo\Application\RoutingErrorMiddleware;
use Solo\Application\RoutingMiddleware;
require __DIR__ . '/../vendor/autoload.php';
$app = new Application(new Config(
basePath: dirname(__DIR__),
routesPath: dirname(__DIR__) . '/app/routes.php',
providers: [HttpServiceProvider::class],
middleware: [RoutingErrorMiddleware::class, RoutingMiddleware::class],
));
$app->run();<?php
// app/routes.php
use App\Controller\UserController;
use Solo\Router\RouteCollector;
return function (RouteCollector $r): void {
$r->get('/users/{id}', [UserController::class, 'show'])->name('users.show');
};The controller comes from the container and gets the request, a new response and the route parameters:
<?php
namespace App\Controller;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
final class UserController
{
public function show(ServerRequestInterface $request, ResponseInterface $response, array $params): ResponseInterface
{
$response->getBody()->write("User {$params['id']}");
return $response;
}
}HttpServiceProvider registers the PSR-17 factory, the incoming request and the emitter: see the quick start.
composer require "solophp/application:^4.0.1"Requirements: PHP 8.3 or later, a PSR-7/PSR-17 implementation, a container and an HTTP emitter. See installation.