chubbyphp/chubbyphp-static-file

A minimal static file middleware for PSR 15.

1.3.0 2023-12-03 19:14 UTC

This package is auto-updated.

Last update: 2024-04-13 20:18:46 UTC


README

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 static file middleware for PSR 15.

Requirements

Installation

Through Composer as chubbyphp/chubbyphp-static-file.

composer require chubbyphp/chubbyphp-static-file "^1.3"

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