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.

Overview

chubbyphp-framework

CI Coverage Status Infection MSI 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 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.

Application workflow

Requirements

Suggest

Router

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

PSR 7 / PSR 17

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

RequestHandler

Router

Server

Skeleton

Migration

Copyright

Dominik Zogg 2021

You might also like...
PSR-15 middleware to geolocate the client using the ip address

middlewares/geolocation ![SensioLabs Insight][ico-sensiolabs] Middleware to geolocate the client using the ip address and Geocoder and save the result

A PSR-15 middleware adapter for react/http

A PSR-15 middleware adapter for react/http Wraps PSR-15 middleware into coroutines using RecoilPHP making them usable within react/http as middleware.

PSR-15 middleware to use Whoops as error handler

middlewares/whoops Middleware to use Whoops as error handler. Requirements PHP = 7.2 A PSR-7 http library A PSR-15 middleware dispatcher Installation

A PSR-15 middleware to handle content negotiation

Content negotiation middleware Motivation Packages like middlewares/negotiation do a very good job to detect the correct content type based on the Acc

PSR-15 compatible middleware for Whoops, the pretty error handler

PSR-15 middleware for Whoops A PSR-15 compatible middleware for Whoops, the fantastic pretty error handler for PHP. Installation You can install the l

An internal redirect mechanism for PSR-15 middleware stacks

HTTP Request Forwarder The aim of this library is to make it possible to pass the HTTP request to another handler, creating a so-called internal redir

An easy to use Fractal wrapper built for Laravel and Lumen applications
An easy to use Fractal wrapper built for Laravel and Lumen applications

An easy to use Fractal wrapper built for Laravel and Lumen applications The package provides a nice and easy wrapper around Fractal for use in your La

An Unleash bundle for Symfony applications to provide an easy way to use feature flags

Unleash Bundle An Unleash bundle for Symfony applications. This provide an easy way to implement feature flags using Gitlab Feature Flags Feature. Ins

A PHP library for the CoinMarketCap API designed to be easy to use.

Help wanted: I don't have enough time to keep updating this library, if you can, don't be shy. Pull requests are welcome. PHP CoinMarketCap API This p

Comments
  • remove mavimo/phpstan-junit formatter (included in phpstan)

    remove mavimo/phpstan-junit formatter (included in phpstan)

    Remove the package mavimo/phpstan-junit since the junit reporting format is included in PHPStan starting from 0.12.4 so no need to extra package 🎉

    I'll really like to see this PR merged (and if you don't have any complains I'll open PR for all other packages in chubbyphp organisation), so I can safely deprecate my package 😄

    Let me know if there is something that you think should be changed here ;)

    PS: I really appreciate if you can mark projects in this orgs as hacktoberfest "allowed" (mean you need to add a tag to each project with label hacktoberfest as reported here https://hacktoberfest.digitalocean.com/hacktoberfest-update )

    opened by mavimo 2
Owner
chubbyphp
Easy to use components for building API and/or web applications with chubbyphp-framework, mezzio (former expressive), slim and others.
chubbyphp
Check a project's code coverage, optionally enforcing a minimum value

coverage-check Display the code coverage for a project using a clover.xml file, optionally enforcing a minimum code coverage percentage. This package

Permafrost Software 15 Aug 9, 2022
A Statamic Pro addon that provides alternative GraphQL queries for collections, entries and global sets.

Statamic Enhanced GraphQL A Statamic CMS GraphQL Addon that provides alternative GraphQL queries for collections, entries and global sets. ⚠️ This is

Grischa Erbe 2 Dec 7, 2021
Like FormRequests, but for validating against a json-schema

JSON Schema Request Laravels Form Request Validation for JSON Schema documents Installation composer require wt-health/laravel-json-schema-request Us

Webtools Health 1 Feb 3, 2022
A PHP replacement layer for the C intl extension that also provides access to the localization data of the ICU library.

A PHP replacement layer for the C intl extension that also provides access to the localization data of the ICU library.

Symfony 2.5k Dec 29, 2022
The efficient and elegant, PSR-7 compliant JSON:API 1.1 client library for PHP

Woohoo Labs. Yang Woohoo Labs. Yang is a PHP framework which helps you to communicate with JSON:API servers more easily. Table of Contents Introductio

Woohoo Labs. 160 Oct 16, 2022
OpenAPI(v3) Validators for Symfony http-foundation, using `league/openapi-psr7-validator` and `symfony/psr-http-message-bridge`.

openapi-http-foundation-validator OpenAPI(v3) Validators for Symfony http-foundation, using league/openapi-psr7-validator and symfony/psr-http-message

n1215 2 Nov 19, 2021
PSR-7 middleware foundation for building and dispatching middleware pipelines

laminas-stratigility From "Strata", Latin for "layer", and "agility". This package supersedes and replaces phly/conduit. Stratigility is a port of Sen

Laminas Project 47 Dec 22, 2022
Tukio is a complete and robust implementation of the PSR-14 Event Dispatcher specification

Tukio is a complete and robust implementation of the PSR-14 Event Dispatcher specification. It supports normal and debug Event Dispatchers, both runtime and compiled Providers, complex ordering of Listeners, and attribute-based registration on PHP 8.

Larry Garfield 70 Dec 19, 2022
Disable Google's FLoC with help of PSR-15 middleware

Disable Google's FLoC with PSR-15 middleware This package will help you disable Google's FLoC. Installation You can install the package via composer:

P7V 9 Dec 14, 2022
It validates PSR-7 messages (HTTP request/response) against OpenAPI specifications

OpenAPI PSR-7 Message (HTTP Request/Response) Validator This package can validate PSR-7 messages against OpenAPI (3.0.x) specifications expressed in Y

The League of Extraordinary Packages 421 Jan 3, 2023