Zf2 Module that sends stream responses with additional features like download resume and speed limit
MIT License
HumusStreamResponseSender is a Zend Framework 2 module that sends stream responses with HTTP Range header, XSendFile & pecl_http support.
"prolic/humus-stream-response-sender": "dev-master"
to your composer.json
php composer.phar install
config/application.config.php
by adding HumusStreamResponseSender
to modules
Sample configuration:
<?php
return array(
'HumusStreamResponseSender' => array(
'enable_speed_limit' => true,
'enable_range_support' => true,
'chunk_size' => 1024 * 1024 // = 1MB/s
),
);
The simplest way to stream a response from a controller, is the stream plugin.
class IndexController extends AbstractActionController
{
public function fileAction()
{
return $this->plugin('stream')->binaryFile('/path/to/my/file');
}
}
If the speed limit switch is set to true, the used chunksize will also be the download speed in bytes per second
The default configuration is: