| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
A minimal PSR-15 middleware that serves static files from a public directory.
Through Composer as chubbyphp/chubbyphp-static-file.
composer require chubbyphp/chubbyphp-static-file "^1.4"Register the middleware before the routing of your PSR-15 based framework, so that static files are served without hitting a route.
<?php
declare(strict_types=1);
namespace App;
use Chubbyphp\StaticFile\StaticFileMiddleware;
use Psr\Http\Message\ResponseFactoryInterface;
use Psr\Http\Message\StreamFactoryInterface;
/** @var ResponseFactoryInterface $responseFactory */
$responseFactory = ...;
/** @var StreamFactoryInterface $streamFactory */
$streamFactory = ...;
$app = ...;
$app->add(new StaticFileMiddleware(
$responseFactory,
$streamFactory,
__DIR__ . '/public'
));The constructor accepts two optional arguments:
$app->add(new StaticFileMiddleware(
$responseFactory,
$streamFactory,
__DIR__ . '/public',
'sha256',
['css' => 'text/css', 'js' => 'text/javascript', 'png' => 'image/png']
));2026 Dominik Zogg
| Back | FazBrowse Home | New Git URL |