Giter Site home page Giter Site logo

igorwfileservebundle's Introduction

FileServeBundle

About

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

Installation

Put the FileServeBundle into the vendor/bundles/Igorw directory:

$ git clone https://github.com/igorw/IgorwFileServeBundle vendor/bundles/Igorw/FileServeBundle

Register the Igorw namespace in your project's autoload script (app/autoload.php):

$loader->registerNamespaces(array(
    'Igorw'                          => __DIR__.'/../vendor/bundles',
));

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',
    'inline' => false,
);

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

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%"

Features

  • Incremental serving of large files
  • Nginx XSendfile

Todo

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.