chubbyphp/chubbyphp-static-file

A minimal static file middleware for PSR 15.

dev-master / 1.0.x-dev 2019-12-10 16:58 UTC

This package is auto-updated.

Last update: 2019-12-10 16:59:04 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.

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 2019