igorw/file-serve-bundle 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

igorw/file-serve-bundle

Composer 安装命令:

composer require igorw/file-serve-bundle

包简介

Symfony2 Bundle for serving protected files.

README 文档

README

About

The FileServeBundle allows you to serve files that are not publicly available, such as private attachments.

Installation

Add the bundle to your composer.json:

{
    "require": {
        "igorw/file-serve-bundle": "~1.0"
    }
}

Add the FileServeBundle to your application's kernel:

public function registerBundles()
{
    $bundles = array(
        // ...
        new Igorw\FileServeBundle\IgorwFileServeBundle(),
        // ...
    );
    // ...
}

Usage

Use the igorw_file_serve.response_factory service to create a FileServe response. The path is relative to the app directory by default.

$response = $this->get('igorw_file_serve.response_factory')->create('../VERSION', 'text/plain');

You can also pass a set of options as the third parameter of the create method.

$options = array(
    'serve_filename' => 'VERSION.txt',
    'absolute_path' => true,
    'inline' => false,
);

$response = $this->get('igorw_file_serve.response_factory')
    ->create('../VERSION', 'text/plain', $options);
  • serve_filename: Filename the browser downloads the file as.
  • absolute_path: If enabled, the bundle will ignore the base_dir option and use the provided filename as an absolute path.

You can configure the factory used, for example to use a nginx XSendfile response factory:

igorw_file_serve:
    factory: sendfile     # The default value is "php"

You can also configure the base directory:

igorw_file_serve:
    base_dir: /files/dir     # The default value is "%kernel.root_dir%"

By default, this bundle does a file_exists check when creating a response object. Recent nginx versions require relative paths, in which case the paths inside of PHP are not actual physical paths. Use the skip_file_exists setting to disable the check.

igorw_file_serve:
    skip_file_exists: true  # The default value is false

Supported factories

  • php
  • sendfile (nginx)
  • xsendfile (apache)

Features

Todo

  • Tests
  • HTTP caching
  • HTTP range requests
  • Lighttpd XSendfile
  • Handle PhpResponse getContent(), setContent()

统计信息

  • 总下载量: 157.22k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 166
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 165
  • Watchers: 9
  • Forks: 16
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2011-12-19

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固