chubbyphp-framework
Description
A based PSR-15 microframework that also sets maximum flexibility with minimum complexity and easy replaceability of the individual components, but also of the framework. It's currently one of the fastest PSR-15 based framework (php-fpm) on the market.
- 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)
Requirements
- php: ^7.4|^8.0
- psr/container: ^1.0|^2.0
- psr/http-factory: ^1.0.1
- psr/http-message-implementation: ^1.0
- psr/http-message: ^1.0.1
- psr/http-server-handler: ^1.0.1
- psr/http-server-middleware: ^1.0.1
- psr/log: ^1.1
Suggest
Router
Any Router which implements Chubbyphp\Framework\Router\RouterInterface
can be used.
- chubbyphp/chubbyphp-framework-router-aura: ^1.0
- chubbyphp/chubbyphp-framework-router-fastroute: ^1.0
- chubbyphp/chubbyphp-framework-router-sunrise: ^1.0
- chubbyphp/chubbyphp-framework-router-symfony: ^1.0
PSR 7 / PSR 17
- bittyphp/http: ^2.0
- guzzlehttp/psr7: ^1.4.2 (with http-interop/http-factory-guzzle: ^1.0)
- nyholm/psr7: ^1.0
- slim/psr7: ^0.5|^1.0
- sunrise/http-message: ^1.0 (with sunrise/http-factory: ^1.0)
- laminas/laminas-diactoros: ^2.0
Installation
Through Composer as chubbyphp/chubbyphp-framework.
composer require chubbyphp/chubbyphp-framework "^3.4" \
chubbyphp/chubbyphp-framework-router-fastroute "^1.1" \
slim/psr7 "^1.3"
Usage
<?php
declare(strict_types=1);
namespace App;
use Chubbyphp\Framework\Application;
use Chubbyphp\Framework\Middleware\ExceptionMiddleware;
use Chubbyphp\Framework\Middleware\RouterMiddleware;
use Chubbyphp\Framework\RequestHandler\CallbackRequestHandler;
use Chubbyphp\Framework\Router\FastRoute\Router;
use Chubbyphp\Framework\Router\Route;
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 RouterMiddleware(new Router([
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;
}
))
]), $responseFactory),
]);
$app->emit($app->handle((new ServerRequestFactory())->createFromGlobals()));
Emitter
Middleware
- CallbackMiddleware
- ExceptionMiddleware
- LazyMiddleware
- MiddlewareDispatcher
- NewRelicRouteMiddleware
- RouterMiddleware
- SlimCallbackMiddleware
- SlimLazyMiddleware
RequestHandler
Router
Server
Skeleton
Migration
Copyright
Dominik Zogg 2021