2017 © Pedro Peláez
 

library slim-download

Slim extension to implement download view render

image

simotod/slim-download

Slim extension to implement download view render

  • Sunday, March 22, 2015
  • by SimoTod
  • Repository
  • 1 Watchers
  • 1 Stars
  • 103 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

slim-download

This is an extension to the SLIM framework vers.2 to implement the download of a file from a route. It can be used to check the user permissions before of permits the downloading of a file, to count the number of download or for something else useful., (*1)

Installation

Using composer you can add use this as your composer.json, (*2)

    {
        "require": {
            "simotod/slim-download": "dev-master"
        }
    }

Usage

    require 'vendor/autoload.php';

    $app = new \Slim\Slim(); 

    $app->get('/download', function () use ($app) {
        //Do some stuff here

        $filepath = "/path/to/file";

        $app->view(new \SimoTod\SlimDownload\DownloadView());
        $app->render($filepath);
    });

    $app->run();

example method

all your requests will be returning a file output. the usage will be $app->render( (string)$FILE_PATH, (array)$DATA); Downladed file use the real name and 'application/octet-stream' as content type. Content type can be overriden by $DATA["CONTENT_TYPE"]. File name can be overriden by $DATA["FILENAME"]., (*3)

    $app->get('/download', function () use ($app) {
        //Do some stuff here

        $filepath = "/path/to/pdf";
        $data = array();
        $data["CONTENT_TYPE"] = "application/pdf";
        $data["FILENAME"] = "sample.pdf";

        $app->view(new \SimoTod\SlimDownload\DownloadView());
        $app->render($filepath);
    });

The Versions

22/03 2015

dev-master

9999999-dev https://github.com/SimoTod/slim-download

Slim extension to implement download view render

  Sources   Download

MIT

The Requires

 

slim view download

22/03 2015

v1.1.0

1.1.0.0 https://github.com/SimoTod/slim-download

Slim extension to implement download view render

  Sources   Download

MIT

The Requires

 

slim view download

22/03 2015

dev-develop

dev-develop https://github.com/SimoTod/slim-download

Slim extension to implement download view render for version 3 of the framework

  Sources   Download

MIT

The Requires

 

slim view download

03/02 2015

v1.0.0

1.0.0.0 https://github.com/SimoTod/slim-download

Slim extension to implement download view render

  Sources   Download

MIT

The Requires

 

slim view download