PHPackages                             diversen/http-send-file - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. diversen/http-send-file

ActiveLibrary[HTTP &amp; Networking](/categories/http)

diversen/http-send-file
=======================

Sends a file to a client, with support for (multiple) range requests. It is also able to throttle the download.

v3.2.0(11mo ago)57345.2k↓26.7%9MITPHP

Since Mar 2Pushed 11mo ago4 watchersCompare

[ Source](https://github.com/diversen/http-send-file)[ Packagist](https://packagist.org/packages/diversen/http-send-file)[ Docs](http://github.com/diversen/http-send-file)[ RSS](/packages/diversen-http-send-file/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (21)Used By (0)

HTTP send file
==============

[](#http-send-file)

Sends a file with support for (multiple) range requests. It is able to throttle the download and adds an etag to the request. It is quite small and simple.

Install
=======

[](#install)

With composer add to your "require" section:

```
composer require diversen/http-send-file

```

Usage example:

```
use Diversen\Sendfile;
$s = new Sendfile();

// if you don't set type - we will try to guess it
$s->setContentType('application/epub+zip');

// if you don't set disposition (file name user agent will see)
// we will make a file name from file
$s->setContentDisposition('test.epub');

// Expires header. Default is a date in the past
$s->setExpires(3600);

// chunks of 40960 bytes per 0.1 secs
// if you don't set this then the values below are the defaults
// approx 40960 bytes per sec
$s->throttle(0.1, 40960);

// file
$file = '/some/dir/test.epub';

// send the file
try {
    $s->send($file);
} catch (\Exception $e) {
    echo $e->getMessage();
}
```

So you could just do like this:

```
use Diversen\Sendfile;
$s = new Sendfile();

// file
$file = '/some/dir/test.epub';

// send the file
try {
    $s->send($file);
} catch (\Exception $e) {
    echo $e->getMessage();
}

// but check the headers if it is not
// working as expected as the guessing
// of content-type does not always work
// correctly.
```

Without sending content-disposition header:

```
// without sending content-disposition header
// 2. param = false
try {
    $s->send($file, false);
} catch (\Exception $e) {
    echo $e->getMessage();
}
```

Test notes
==========

[](#test-notes)

Build image:

```
docker build -t php-apache2 .

```

Run the docker image:

```
docker run -d -p 8080:80 -v $(pwd):/var/www/html --name test-send-file php-apache2

```

Enable autoloading:

```
composer install

```

Go to the browser at:

Or use curl, e.g.:

Test that download is resumable:

```
curl -v -L -C - -o test.pdf http://localhost:8080/test/slow_download.php

```

Credits
=======

[](#credits)

Much of the code is taken (and rewritten) from here:

The process is nicely explained here:

MIT © [Dennis Iversen](https://github.com/diversen)

###  Health Score

51

—

FairBetter than 96% of packages

Maintenance50

Moderate activity, may be stable

Popularity47

Moderate usage in the ecosystem

Community17

Small or concentrated contributor base

Maturity72

Established project with proven stability

 Bus Factor1

Top contributor holds 82.2% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~197 days

Recently: every ~203 days

Total

20

Last Release

350d ago

Major Versions

v1.0.91 → v2.0.02017-09-13

v2.0.3 → v3.0.02023-03-13

### Community

Maintainers

![](https://www.gravatar.com/avatar/23ed91d104f16d10414811ecdafbd5c80a660e658d80ccaadf84f512cfb50629?d=identicon)[diversen](/maintainers/diversen)

---

Top Contributors

[![diversen](https://avatars.githubusercontent.com/u/142675?v=4)](https://github.com/diversen "diversen (60 commits)")[![diversen7](https://avatars.githubusercontent.com/u/124348937?v=4)](https://github.com/diversen7 "diversen7 (10 commits)")[![web-elements](https://avatars.githubusercontent.com/u/3841780?v=4)](https://github.com/web-elements "web-elements (2 commits)")[![iongion](https://avatars.githubusercontent.com/u/867609?v=4)](https://github.com/iongion "iongion (1 commits)")

---

Tags

http-send-filehttpfiledownloadthrottleresume

### Embed Badge

![Health badge](/badges/diversen-http-send-file/health.svg)

```
[![Health](https://phpackages.com/badges/diversen-http-send-file/health.svg)](https://phpackages.com/packages/diversen-http-send-file)
```

###  Alternatives

[aplus/http

Aplus Framework HTTP Library

2311.6M10](/packages/aplus-http)[padraic/humbug_get_contents

Secure wrapper for accessing HTTPS resources with file\_get\_contents for PHP 5.3+

1255.3M5](/packages/padraic-humbug-get-contents)[rtheunissen/guzzle-rate-limiter

Guzzle 6 middleware used to delay requests dynamically

52177.2k1](/packages/rtheunissen-guzzle-rate-limiter)[amphp/http-server-static-content

Static content request handler for Amp's HTTP server.

2167.2k12](/packages/amphp-http-server-static-content)[mhndev/slim-file-response

Slim File Response

112.5k](/packages/mhndev-slim-file-response)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
