PHPackages                             jkuchar/bigfiletools - 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. [File &amp; Storage](/categories/file-storage)
4. /
5. jkuchar/bigfiletools

ActiveLibrary[File &amp; Storage](/categories/file-storage)

jkuchar/bigfiletools
====================

Tools that allows you to manipulate files over 2GB in PHP.

v2.0.0(10y ago)50141.8k—6.8%11[2 issues](https://github.com/jkuchar/BigFileTools/issues)[2 PRs](https://github.com/jkuchar/BigFileTools/pulls)7New BSDPHPPHP &gt;= 5.6.0

Since May 27Pushed 6y ago2 watchersCompare

[ Source](https://github.com/jkuchar/BigFileTools)[ Packagist](https://packagist.org/packages/jkuchar/bigfiletools)[ RSS](/packages/jkuchar-bigfiletools/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (7)Dependencies (2)Versions (12)Used By (7)

BigFileTools
============

[](#bigfiletools)

[![Join the chat at https://gitter.im/jkuchar/BigFileTools](https://camo.githubusercontent.com/dcbe97e9c74eaa954065a0de61ba779a253a2babdde727d8105bb2ab37ec2b1e/68747470733a2f2f6261646765732e6769747465722e696d2f6a6b75636861722f42696746696c65546f6f6c732e737667)](https://gitter.im/jkuchar/BigFileTools?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)[![Latest Stable Version](https://camo.githubusercontent.com/9ce1d78a440504911db59f57f68a31e84b7aaa2264175b099a97011a2d106063/68747470733a2f2f706f7365722e707567782e6f72672f6a6b75636861722f62696766696c65746f6f6c732f762f737461626c65)](https://packagist.org/packages/jkuchar/bigfiletools)[![License](https://camo.githubusercontent.com/0de2b3ce0a8d24feb869b2bea1d1654993931f838c1bed1b736b405c075964af/68747470733a2f2f706f7365722e707567782e6f72672f6a6b75636861722f62696766696c65746f6f6c732f6c6963656e7365)](https://packagist.org/packages/jkuchar/bigfiletools)[![Total Downloads](https://camo.githubusercontent.com/88bba87475c5071b2f1933c155eac51a4768c199e9a5b54c44fa373b7155ec01/68747470733a2f2f706f7365722e707567782e6f72672f6a6b75636861722f62696766696c65746f6f6c732f646f776e6c6f616473)](https://packagist.org/packages/jkuchar/bigfiletools)[![Monthly Downloads](https://camo.githubusercontent.com/0635027b42cb07ba63d22d7b48a0562c13043443929fcf81e8e3809c8139a223/68747470733a2f2f706f7365722e707567782e6f72672f6a6b75636861722f62696766696c65746f6f6c732f642f6d6f6e74686c79)](https://packagist.org/packages/jkuchar/bigfiletools)[![Build Status - Linux](https://camo.githubusercontent.com/ea8dcef68eba612b3fd69047f684a4d3452518924831d293baff44947051243d/68747470733a2f2f7472617669732d63692e6f72672f6a6b75636861722f42696746696c65546f6f6c732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/jkuchar/BigFileTools)[![Build status - Windows](https://camo.githubusercontent.com/4d4379cc5918a4353bab11d87ea86d11a419d219f8e8228c68e63a18bc737d38/68747470733a2f2f63692e6170707665796f722e636f6d2f6170692f70726f6a656374732f7374617475732f7635616632736f6e33336a34343378772f6272616e63682f6d61737465723f7376673d74727565)](https://ci.appveyor.com/project/jkuchar/bigfiletools/branch/master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/fd79d8a9de49d0e939caebcc394ab99e3a94ed9187e46d24b641ff18df475213/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6a6b75636861722f42696746696c65546f6f6c732f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/jkuchar/BigFileTools/?branch=master)[![Code Climate](https://camo.githubusercontent.com/f04471fdff2d40888630575e7b8646c9088d705fd7410e1221555deffe11511f/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f6a6b75636861722f42696746696c65546f6f6c732f6261646765732f6770612e737667)](https://codeclimate.com/github/jkuchar/BigFileTools)[API Docs](https://codedoc.pub/jkuchar/BigFileTools)

This project is collection of hacks that are needed to manipulate files over 2GB in PHP (even on 32-bit systems). Currently there is support for getting **exact file size**. This project started as answer to [stackoverflow question](http://stackoverflow.com/questions/5501451/php-x86-how-to-get-filesize-of-2gb-file-without-external-program).

Simplest usage:

```
$file = BigFileTools\BigFileTools::createDefault()->getFile(__FILE__);
echo "This file has " . $file->getSize() . " bytes\n";
```

Will produce output:

```
This file has 176 bytes

```

Please note, that `getSize()` returns [Brick](https://github.com/brick/math)\\[BigInteger](http://brick.io/math/class-Brick.Math.BigInteger.html). This is due to fact that PHP's internal integer can be too small for huge files.

To get *approximate* value of file size you can convert `BigInteger` into `float`. Please note that by doing this you will *loose precision*.

**Tip:** You can configure BigFileTools in any way you want. (no static dependencies included) There is example in example directory prepared for this scenario.

Will this really work?
----------------------

[](#will-this-really-work)

This project is automatically tested on Linux, Mac OS X and Windows. More about testing in [tests directory](tests).

Under the hood
--------------

[](#under-the-hood)

To get insight into what is happening we need a little introduction in how numbers are represented in digital world.

The problem lies in the fact that PHP uses 32-bit signed integer on most platforms. PHPx64 for Linux 64-bit version uses 64-bit so you do not need this library there anymore. On the other hand 64-bit version of PHP for 64-bit Windows uses 32-bit integer. Because PHP uses signed integers this means that there is one bit for sign (+-) and rest is used for value.

```
32-bit signed integer max value: +2^31 =             2 147 483 648 ~             2 gigabytes
64-bit signed integer max value: +2^63 = 9 223 372 036 854 775 808 ~ 9 223 372 000 gigabytes

```

To overcome this problem this library uses string representation of numbers which means that only you RAM is limit of number size.

**Caution:** There are tons of non-solutions for this problem. Most of them looks like `sprintf("%u", filesize($file));`. This does NOT solve problem. If just shifts it a little. The `%u` assumes give value as **unsigned** integer. This means that first signing bit is treated also as a value. Unfortunately this means that boundary was just shifted from 2 GB limit to 4 GB.

Second problem is that standard file manipulation APIs fails with strange errors or returns weird values. That is why BigFileTools has `drivers`. They are by default executed from the fastest to the slowest and unsupported ones are skipped.

### Drivers

[](#drivers)

Currently there is support for *size drivers* - drivers for obtaining file size.

Selecting default drivers and their order of drivers is done based on two factors - availability and speed.

DriverTime (s) ↓Runtime requirementsPlatformCurlDriver0.00045299530029297CURL extension-NativeSeekDriver0.00052094459533691--ComDriver0.0031449794769287COM+.NET extensionWindows onlyExecDriver0.042937040328979exec() enabledWindows, Linux, OS XNativeRead2.7670161724091--In default configuration size drivers are ordered by speed and unavailable ones are skipped. This means that in default configuration you do not need to worry about compatibility.

Requirements
------------

[](#requirements)

Please follow [Composer](https://getcomposer.org/) requirements.

To speed things up (e.g. in production) **I recommend installing CURL extension** which enables you to use the fastest driver.

###  Health Score

41

—

FairBetter than 87% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity46

Moderate usage in the ecosystem

Community21

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 99% 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 ~128 days

Recently: every ~11 days

Total

9

Last Release

3736d ago

Major Versions

1.1.1 → 2.0.0RC12016-02-01

1.1.2 → v2.0.02016-03-17

PHP version history (2 changes)1.0.x-devPHP &gt;= 5.2.0

2.0.0RC1PHP &gt;= 5.6.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/133822?v=4)[Jan Kuchař](/maintainers/jkuchar)[@jkuchar](https://github.com/jkuchar)

---

Top Contributors

[![jkuchar](https://avatars.githubusercontent.com/u/133822?v=4)](https://github.com/jkuchar "jkuchar (95 commits)")[![gitter-badger](https://avatars.githubusercontent.com/u/8518239?v=4)](https://github.com/gitter-badger "gitter-badger (1 commits)")

### Embed Badge

![Health badge](/badges/jkuchar-bigfiletools/health.svg)

```
[![Health](https://phpackages.com/badges/jkuchar-bigfiletools/health.svg)](https://phpackages.com/packages/jkuchar-bigfiletools)
```

###  Alternatives

[laravel/framework

The Laravel Framework.

34.7k532.1M19.2k](/packages/laravel-framework)[illuminate/database

The Illuminate Database package.

3.0k54.1M11.0k](/packages/illuminate-database)[brick/money

Money and currency library

1.9k40.4M139](/packages/brick-money)[illuminate/validation

The Illuminate Validation package.

18837.7M1.6k](/packages/illuminate-validation)[bavix/laravel-wallet

It's easy to work with a virtual wallet.

1.3k1.2M18](/packages/bavix-laravel-wallet)[flow-php/etl

PHP ETL - Extract Transform Load - Abstraction

377559.7k85](/packages/flow-php-etl)

PHPackages © 2026

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