PHPackages                             landall/filesize - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. landall/filesize

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

landall/filesize
================

A library to display and parse readable file sizes (for PHP7)

v1.0.1(1mo ago)17MITPHP

Since Apr 17Pushed 1mo agoCompare

[ Source](https://github.com/landall/filesize)[ Packagist](https://packagist.org/packages/landall/filesize)[ RSS](/packages/landall-filesize/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (1)Versions (2)Used By (0)

📦 FileSize — Human-friendly file size handling for PHP
======================================================

[](#-filesize--human-friendly-file-size-handling-for-php)

[![Latest Version on Packagist](https://camo.githubusercontent.com/c94b2f656537840bd46d8ea0de932173ca5e3ce50571d390c607d4970d19c141/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c316e6e61682f66696c6573697a652e737667)](https://packagist.org/packages/l1nnah/file-size)[![Tests](https://camo.githubusercontent.com/22e9a76d13d704dc8f6a06052ec9650aef74a3a999d02e93d5234bc9d77c43ee/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6c316e6e61682f66696c6573697a652f72756e2d74657374732e796d6c3f6272616e63683d6d61696e)](https://github.com/tonsoo/filesize/actions)[![License](https://camo.githubusercontent.com/2c532629ec648dd098b63e77d5b36e3faa89e2cf20d059fec1e75057753a6803/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6c316e6e61682f66696c6573697a652e737667)](https://github.com/tonsoo/filesize/blob/main/LICENSE)

A lightweight and extensible PHP library to parse, format, and convert file sizes in a human-readable and localized way.

cloned from

modified for PHP7

🚀 Features
----------

[](#-features)

- Convert bytes to human-readable formats (KB, MB, GB, etc.);
- Format file sizes with custom decimal and thousand separators;
- Parse strings like `"123.45 MB"` or `"1.234,56 KB"` into bytes;
- Multi-locale support with optional Laravel integration;
- Fully tested with PHPUnit.

📥 Installation
--------------

[](#-installation)

```
composer require landall/filesize
```

🔧 Usage
-------

[](#-usage)

Converting bytes to human-readable format:

```
use L1nnah\FileSize\FileSizeConverter;
use L1nnah\FileSize\FileSizeUnits;

$valueInBytes = 123456;
$converter = new FileSizeConverter($valueInBytes);
$readable = $converter->convertTo(FileSizeUnits::KB);

echo $readable->toFixed(2); // Expected: "120.56 KB"
```

---

Parsing from human-readable string:

```
use L1nnah\FileSize\FileSizeConverter;

$converter = FileSizeConverter::fromString("1.234,56 MB");
echo $converter->sizeInBytes; // Expected: "1294467072"
```

✅ Testing
---------

[](#-testing)

PHPUnit was used for testing with the commands:

```
vendor/bin/phpunit tests/FileSizeTest.php
vendor/bin/phpunit tests/FileSizeFromStringTest.php
```

📫 Credits
---------

[](#-credits)

Developed by **tonsoo** and published under the nickname of **l1nnah**.

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance89

Actively maintained with recent releases

Popularity6

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity33

Early-stage or recently created project

 Bus Factor1

Top contributor holds 66.7% 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

Unknown

Total

1

Last Release

53d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/7061302?v=4)[landall](/maintainers/landall)[@landall](https://github.com/landall)

---

Top Contributors

[![tonsoo](https://avatars.githubusercontent.com/u/81568701?v=4)](https://github.com/tonsoo "tonsoo (4 commits)")[![landall](https://avatars.githubusercontent.com/u/7061302?v=4)](https://github.com/landall "landall (2 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/landall-filesize/health.svg)

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

###  Alternatives

[unclecheese/display-logic

Allows assignment of conditions for display and hide of specific form fields based on client side behavior.

771.1M109](/packages/unclecheese-display-logic)[tomaj/prepositioner

Preposition replace library

108.3k](/packages/tomaj-prepositioner)

PHPackages © 2026

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