2017 © Pedro Peláez
 

symfony-bundle file-serve-bundle

Symfony2 Bundle for serving protected files.

image

igorw/file-serve-bundle

Symfony2 Bundle for serving protected files.

  • Wednesday, January 22, 2014
  • by igorw
  • Repository
  • 10 Watchers
  • 175 Stars
  • 103,373 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 18 Forks
  • 6 Open issues
  • 5 Versions
  • 4 % Grown

The README.md

FileServeBundle

About

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

Installation

Add the bundle to your composer.json:, (*2)

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

Add the FileServeBundle to your application's kernel:, (*3)

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., (*4)

$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., (*5)

$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:, (*6)

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

You can also configure the base directory:, (*7)

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., (*8)

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()

The Versions

22/01 2014

dev-master

9999999-dev

Symfony2 Bundle for serving protected files.

  Sources   Download

MIT

The Requires

 

The Development Requires

file-system sendfile

06/01 2014

v1.0.3

1.0.3.0

Symfony2 Bundle for serving protected files.

  Sources   Download

MIT

The Requires

 

The Development Requires

file-system sendfile

24/10 2012

v1.0.2

1.0.2.0

Symfony2 Bundle for serving protected files.

  Sources   Download

MIT

The Requires

 

The Development Requires

file-system sendfile

24/10 2012

v1.0.1

1.0.1.0

Symfony2 Bundle for serving protected files.

  Sources   Download

MIT

The Requires

 

The Development Requires

file-system sendfile

16/10 2012

v1.0.0

1.0.0.0

Symfony2 Bundle for serving protected files.

  Sources   Download

MIT

The Development Requires

file-system sendfile