simotod/slim-download 问题修复 & 功能扩展

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

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

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

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-02-03