chubbyphp/chubbyphp-static-file

A minimal static file middleware for PSR 15.

1.0.0 2020-04-27 05:33 UTC

This package is auto-updated.

Last update: 2020-06-26 06:24:47 UTC


README

Build Status Coverage Status Total Downloads Monthly Downloads Latest Stable Version Latest Unstable Version

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.0"

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

Dominik Zogg 2020