SkillAgentSearch skills...

Jugoya

A simple HTTP application builder using PSR-15 HTTP Server Request Handler and Middleware.

Install / Use

/learn @n1215/Jugoya
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

Jugoya(十五夜)🌕

Latest Stable Version License Build Status Code Coverage Scrutinizer Code Quality

A simple HTTP application builder using PSR-15 HTTP Server Request Handler and Middleware.

Jugoya is the Japanese full moon festival on the 15th day of the eighth month of the traditional Japanese calendar.

PSR-15 HTTP Server Handler and Middleware

psr15_middleware

See php-fig/fig-standards

What Jugoya does

Jugoya create a new instance of RequestHandlerInterface from a instance of RequestHandlerInterface and instances of MiddlewareInterface. composition

Code Example

// 1. register handler and middleware dependencies to the PSR-11 Container
/** @var \Psr\Container\ContainerInterface $container */
$container = new YourContainer();
//
// do stuff
//


// 2. create a builder
$builder = \N1215\Jugoya\RequestHandlerBuilder::fromContainer($container);

// LazyRequestHandlerBuilder resolves handler and middleware lazily.
// $builder = \N1215\Jugoya\LazyRequestHandlerBuilder::fromContainer($container);

// 3. build a request handler
/**
 * You can use one of
 *   * an instance of PSR-15 RequestHandlerInterface
 *   * a callable having the same signature with PSR-15 RequestHandlerInterface
 *   * a string identifier of a PSR-15 RequestHandlerInterface instance in the PSR-11 Container
 *
 * @var RequestHandlerInterface|callable|string $coreHandler
 *
 */
$coreHandler = new YourApplication();

/** @var RequestHandlerInterface $handler */
$handler = $builder->build($coreHandler, [

        // You can use instances of PSR-15 MiddlewareInterface
        new YourMiddleware(),

        // or callables having the same signature with PSR-15 MiddlewareInterface
        function(ServerRequestInterface $request, RequestHandlerInterface $handler) {
            // do stuff
            $response = $handler->handle($request);
            // do stuff
            return $response;
        },

        // or string identifiers of PSR-15 MiddlewareInterface instances in the PSR-11 Container
        YourMiddleware::class,
    ]);


// 4. handle a PSR-7 Sever Request
/** @var Psr\Http\Message\ServerRequestInterface $request */
$request = \Zend\Diactoros\ServerRequestBuilder::fromGlobals();
/** @var \Psr\Http\Message\ResponseInterface $response */
$response = $handler->handle($request);

Class diagrams

Jugoya

jugoya

Resolver

resolver

Wrapper

wrapper

License

The MIT License (MIT). Please see LICENSE for more information.

View on GitHub
GitHub Stars5
CategoryDevelopment
Updated1y ago
Forks0

Languages

PHP

Security Score

75/100

Audited on Apr 30, 2024

No findings