Skip to content

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.

License

Notifications You must be signed in to change notification settings

chubbyphp/chubbyphp-framework

Folders and files

NameName
Last commit message
Last commit date

Latest commit

6b0b73f · Mar 12, 2025
Mar 6, 2025
Sep 25, 2022
Aug 7, 2022
Jan 7, 2025
Feb 28, 2025
Mar 12, 2025
Dec 2, 2023
Oct 1, 2022
Jan 21, 2025
Feb 28, 2025
Mar 12, 2025
Feb 27, 2022
Dec 8, 2024
Dec 2, 2023
Feb 7, 2021

Repository files navigation

chubbyphp-framework

CI Coverage Status Mutation testing badge Latest Stable Version Total Downloads Monthly Downloads

bugs code_smells coverage duplicated_lines_density ncloc sqale_rating alert_status reliability_rating security_rating sqale_index vulnerabilities

Description

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.

Workflow

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 "^5.2" \
    chubbyphp/chubbyphp-framework-router-fastroute "^2.1" \
    slim/psr7 "^1.7"

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

Emitter

Middleware

RequestHandler

Router

Server

Skeleton

Migration

Copyright

2025 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

License

Stars

Watchers

Forks

Packages

No packages published

Languages