PHPackages                             dcarbone/curl-file-header-extractor - 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. dcarbone/curl-file-header-extractor

Abandoned → [dcarbone/curl-header-extractor](/?search=dcarbone%2Fcurl-header-extractor)ArchivedLibrary[HTTP &amp; Networking](/categories/http)

dcarbone/curl-file-header-extractor
===================================

Utility to extract headers from PHP CURL to file request.

v3.0.3(5y ago)016MITPHPPHP &gt;=7.4

Since Jan 24Pushed 5y ago1 watchersCompare

[ Source](https://github.com/dcarbone/curl-header-extractor)[ Packagist](https://packagist.org/packages/dcarbone/curl-file-header-extractor)[ RSS](/packages/dcarbone-curl-file-header-extractor/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (6)DependenciesVersions (10)Used By (0)

curl-header-extractor
=====================

[](#curl-header-extractor)

Utility to extract headers from PHP CURL request.

Installation
============

[](#installation)

While it is advisable to use [Composer](https://getcomposer.org/), this lib is simple enough to be used without it.

Composer Require entry:

```
{
    "dcarbone/curl-header-extractor": "v3.0.*"
}
```

Usage
=====

[](#usage)

There are 3 methods available:

### [getHeaderAndBody](./src/CURLHeaderExtractor.php#L168)

[](#getheaderandbody)

This method accepts a single argument that may be:

- Full path to the file
- File resource created with [fopen](http://php.net/manual/en/function.fopen.php) with at least read permissions.
- String of response data

The response will be an array with the following structure:

```
array(
    // array of headers,
    // string of body content
);
```

#### Example:

[](#example)

```
list($headers, $body) = \DCarbone\CURLHeaderExtractor::getHeaderAndBody($input);
```

where `$headers` will be an array of headers, or NULL if no headers were found, and `$body` will be the entire contents of the body.

#### Note:

[](#note)

This method CAN be very expensive to use if you are working with particularly large responses, as the end result will be the entire contents of the file loaded into memory.

If you wish to extract JUST the headers, the below methods might serve you better.

### [extractHeadersAndBodyStartOffset](./src/CURLHeaderExtractor.php#L81)

[](#extractheadersandbodystartoffset)

This method will return an array with the following structure:

```
array(
    // array of headers,
    // integer representing the byte offset of the beginning of the body
);
```

#### Example:

[](#example-1)

```
list($headers, $bodyByteOffset) = \DCarbone\CURLHeaderExtractor::extractHeadersAndBodyStartOffset($input);
```

If no headers were seen in the file, `$headers` in the above example will be NULL and the byte offset will be 0.

### [removeHeadersAndMoveFile](./src/CURLHeaderExtractor.php#L102)

[](#removeheadersandmovefile)

This method will strip the file of the headers, copy the body to a new file, and then delete the old file.

#### Example:

[](#example-2)

```
\DCarbone\CURLHeaderExtractor::removeHeadersAndMoveFile($file, 'my_new_filename.ext');
```

If you executed the [extractHeadersAndBodyStartOffset](./src/CURLHeaderExtractor.php#L81) method already, you may pass in the body start offset integer in as the 3rd argument.

Invoking
--------

[](#invoking)

To make this class easier to work with as a "helper", it implements the [PHP magic method \_\_invoke](http://php.net/manual/en/language.oop5.magic.php#object.invoke) (you can see the implementation [here](./src/CURLHeaderExtractor.php#L67)).

This allows you to do something like this:

```
$extractor = new \DCarbone\CURLHeaderExtractor();

list($headers, $body) = $extractor($input);
```

You can, of course, access the other methods as you normally would any static method:

```
list($headers, $bodyByteOffset) = $extractor::extractHeadersAndBodyStartOffset($input);
```

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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 ~231 days

Recently: every ~404 days

Total

9

Last Release

1910d ago

Major Versions

1.0.0 → 2.0.02016-06-08

2.0.3 → v3.0.02021-01-28

PHP version history (2 changes)1.0.0PHP &gt;=5.3.3

v3.0.0PHP &gt;=7.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/385c0c0eae1b51f1e81ee464ff6bfb3cce32589ac252ca68cc3a8aec2e3ada14?d=identicon)[dcarbone](/maintainers/dcarbone)

---

Top Contributors

[![dcarbone](https://avatars.githubusercontent.com/u/1392439?v=4)](https://github.com/dcarbone "dcarbone (14 commits)")

---

Tags

composerextract-headersphp-curlhttpresponsephpcurlfileheaderheadersextractor

### Embed Badge

![Health badge](/badges/dcarbone-curl-file-header-extractor/health.svg)

```
[![Health](https://phpackages.com/badges/dcarbone-curl-file-header-extractor/health.svg)](https://phpackages.com/packages/dcarbone-curl-file-header-extractor)
```

###  Alternatives

[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)
