A minimal, highly performant middleware PSR-15 microframework built with as little complexity as possible, aimed primarily at those developers who want to understand all the vendors they use.
- Basic Coding Standard (1)
- Coding Style Guide (2)
- Logger Interface (3)
- Autoloading Standard (4)
- HTTP Message Interface (7)
- Container Interface (11)
- HTTP Handlers (15)
- HTTP Factories (17)
- php: ^8.1
- chubbyphp/chubbyphp-http-exception: ^1.1
- psr/container: ^1.1.2|^2.0.2
- psr/http-factory-implementation: ^1.0
- psr/http-factory: ^1.0.2
- psr/http-message-implementation: ^1.0|^2.0
- psr/http-message: ^1.1|^2.0
- psr/http-server-handler: ^1.0.2
- psr/http-server-middleware: ^1.0.2
- psr/log: ^2.0|^3.0
Any Router which implements Chubbyphp\Framework\Router\RouteMatcherInterface
can be used.
- guzzlehttp/psr7: ^2.6.1 (with http-interop/http-factory-guzzle: ^1.2)
- laminas/laminas-diactoros: ^3.3
- nyholm/psr7: ^1.8.1
- slim/psr7: ^1.6.1
- sunrise/http-message: ^3.0
Through Composer as chubbyphp/chubbyphp-framework.
composer require chubbyphp/chubbyphp-framework "^5.1" \
chubbyphp/chubbyphp-framework-router-fastroute "^2.1" \
slim/psr7 "^1.5"
<?php
declare(strict_types=1);
namespace App;
use Chubbyphp\Framework\Application;
use Chubbyphp\Framework\Middleware\ExceptionMiddleware;
use Chubbyphp\Framework\Middleware\RouteMatcherMiddleware;
use Chubbyphp\Framework\RequestHandler\CallbackRequestHandler;
use Chubbyphp\Framework\Router\FastRoute\RouteMatcher;
use Chubbyphp\Framework\Router\Route;
use Chubbyphp\Framework\Router\RoutesByName;
use Psr\Http\Message\ServerRequestInterface;
use Slim\Psr7\Factory\ResponseFactory;
use Slim\Psr7\Factory\ServerRequestFactory;
require __DIR__.'/vendor/autoload.php';
$responseFactory = new ResponseFactory();
$app = new Application([
new ExceptionMiddleware($responseFactory, true),
new RouteMatcherMiddleware(new RouteMatcher(new RoutesByName([
Route::get('/hello/{name:[a-z]+}', 'hello', new CallbackRequestHandler(
static function (ServerRequestInterface $request) use ($responseFactory) {
$response = $responseFactory->createResponse();
$response->getBody()->write(sprintf('Hello, %s', $request->getAttribute('name')));
return $response;
}
))
]))),
]);
$app->emit($app->handle((new ServerRequestFactory())->createFromGlobals()));
- CallbackMiddleware
- ExceptionMiddleware
- LazyMiddleware
- MiddlewareDispatcher
- RouteMatcherMiddleware
- SlimCallbackMiddleware
- SlimLazyMiddleware
- CallbackRequestHandler
- LazyRequestHandler
- RouteRequestHandler
- SlimCallbackRequestHandler
- SlimLazyRequestHandler
2024 Dominik Zogg