chubbyphp / chubbyphp-static-file
A minimal static file middleware for PSR 15.
1.3.0
2023-12-03 19:14 UTC
Requires
- php: ^8.1
- psr/http-factory: ^1.0.2
- psr/http-message: ^1.1|^2.0
- psr/http-server-handler: ^1.0.2
- psr/http-server-middleware: ^1.0.2
Requires (Dev)
- chubbyphp/chubbyphp-dev-helper: dev-master
- chubbyphp/chubbyphp-mock: ^1.6.1
- infection/infection: ^0.27.8
- php-coveralls/php-coveralls: ^2.7.0
- phpstan/extension-installer: ^1.3.1
- phpstan/phpstan: ^1.10.45
- phpunit/phpunit: ^10.4.2
This package is auto-updated.
Last update: 2024-12-07 16:15:20 UTC
README
Description
A minimal static file middleware for PSR 15.
Requirements
- php: ^8.2
- psr/http-factory: ^1.0.2
- psr/http-message: ^1.1|^2.0
- psr/http-server-handler: ^1.0.2
- psr/http-server-middleware: ^1.0.2
Installation
Through Composer as chubbyphp/chubbyphp-static-file.
composer require chubbyphp/chubbyphp-static-file "^1.4"
Usage
<?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 = ...; // add the static file middleware before the routing your PSR15 based framework $app->add(new StaticFileMiddleware( $responseFactory, $streamFactory, __DIR__ . '/public' ));
Copyright
2024 Dominik Zogg