simotod/slim-download
最新稳定版本:v1.1.0
Composer 安装命令:
composer require simotod/slim-download
包简介
Slim extension to implement download view render
关键字:
README 文档
README
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.
##Installation Using composer you can add use this as your composer.json
{
"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"].
$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); });
统计信息
- 总下载量: 123
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-02-03