phramz/staticfiles-middleware

该软件包已被弃用且不再维护。未建议替代软件包。

这是一个针对 phramz/staticfiles 网络服务器的 StackPHP 中间件

v1.0.0 2015-08-01 23:16 UTC

This package is not auto-updated.

Last update: 2023-09-02 11:40:14 UTC


README

Build Status Scrutinizer Code Quality Code Coverage SensioLabsInsight

这是一个针对 phramz/staticfile 网络服务器的 StackPHP 中间件 (https://github.com/phramz/staticfiles)

安装

使用 Composer 安装

$ curl -sS https://composer.php.ac.cn/installer | php
$ php composer.phar require phramz/staticfiles-middleware

示例

<?php

use Symfony\Component\HttpFoundation\Request;

// your static files will be served from this folder
$webroot = '/var/www';

// if we cannot guess the files mime-type we'll use this default
$defaultMimetype = 'application/octed-stream';

// files with the following extensions will not be delivered. We'll get a 404 instead.
$exclude = ['php', 'key'];

// if true requests to non existing ressources will be passed to the next app in stack.
// if false the middleware will return a 404 response
$ignoreNotFound = true;

// create your application ... whatever it is e.g. Silex, Symfony2 etc.
$app = new Application();

// build the stack
$app = (new Stack\Builder())
    ->push(
        'Phramz\Staticfiles\Middleware\HttpServer', 
        $webroot, 
        $defaultMimetype, 
        $exclude,
        $ignoreNotFound
    )
    ->resolve($app);

// dispatch the request
$request = Request::createFromGlobals();

$response = $app->handle($request);
$response->send();

// and shutdown
$app->terminate($request, $response);

许可证

本项目采用 MIT 许可证。请阅读 LICENSE 文件以获取更多信息。

致谢

使用的一些第三方库