PHP code example of chubbyphp / chubbyphp-static-file
1. Go to this page and download the library: Download chubbyphp/chubbyphp-static-file library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
chubbyphp / chubbyphp-static-file example snippets
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'
));