FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

chubbyphp/chubbyphp-framework: 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. · GitHub

Repository files navigation

chubbyphp-framework

Description

A minimal, highly performant middleware microframework built with as little complexity as possible, aimed primarily at those developers who want to understand all the vendors they use. It is built on PSR-7 (HTTP message), PSR-15 (handlers / middleware) and PSR-17 (HTTP factories), with optional PSR-11 container and PSR-3 logger integration.

Requirements

Suggest

Router

Any Router which implements Chubbyphp\Framework\Router\RouteMatcherInterface can be used.

PSR 7 / PSR 17

Installation

Through Composer as chubbyphp/chubbyphp-framework.

composer require chubbyphp/chubbyphp-framework "^6.1" \
    chubbyphp/chubbyphp-framework-router-fastroute "^2.3.3" \
    slim/psr7 "^1.8"

Usage

<?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()));

Or with the ApplicationBuilder facade, which wires the very same middleware pipe:

<?php

declare(strict_types=1);

namespace App;

use Chubbyphp\Framework\Facade\ApplicationBuilder;
use Chubbyphp\Framework\RequestHandler\CallbackRequestHandler;
use Chubbyphp\Framework\Router\FastRoute\RouteMatcher;
use Chubbyphp\Framework\Router\RoutesByNameInterface;
use Psr\Http\Message\ServerRequestInterface;
use Slim\Psr7\Factory\ResponseFactory;
use Slim\Psr7\Factory\ServerRequestFactory;

require __DIR__.'/vendor/autoload.php';

$responseFactory = new ResponseFactory();
$createRouteMatcher = static fn (RoutesByNameInterface $routes) => new RouteMatcher($routes);

$app = ApplicationBuilder::create($responseFactory, $createRouteMatcher, debug: true)
    ->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;
        }
    ))
    ->build();

$app->emit($app->handle((new ServerRequestFactory())->createFromGlobals()));

Emitter

Facade

Middleware

RequestHandler

Router

Server

Skeleton

Migration

Copyright

2026 Dominik Zogg

About

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.

Topics

Resources

Stars

137 stars

Watchers

4 watching

Forks

Releases

Packages

Used by

Contributors

Languages


Back | FazBrowse Home | New Git URL