codeinc/human-readable-file-size
Convert raw byte values into clean, human-readable file size strings with this lightweight PHP package. Configurable precision, units, and formatting make it easy to show sizes like 1.5 MB anywhere, and it works seamlessly in Laravel or any PHP project.
Consider it only when all of the following hold:
Number::fileSize() (Laravel 11+ has this in core).Look elsewhere or build in-house when:
Number::fileSize($bytes, precision: 2) covers this with zero added dependency.0 B / null / negative / very large values, and localized unit strings are exactly where micro-packages tend to fall short — and exactly what a product usually ends up needing.Executives: This is not a strategic dependency. It solves a cosmetic display problem — turning 1048576 into 1 MB — that we can cover with framework-native code at zero ongoing cost and zero third-party risk. Given the package's minimal adoption (5 stars, 0 dependents) and lack of releases since 2023, adopting it would trade a tiny amount of saved effort for an unaudited link in our supply chain. Recommendation: do not adopt; assign roughly one hour of engineering to a shared, tested helper.
Engineering: codeinchq/human-readable-file-size is a micro-utility that formats byte counts as human-readable strings. It is functionally equivalent to Laravel 11's Number::fileSize() and to a short internal helper over a units array. The trade is straightforward: we would swap ten lines of code we control and can test for a dependency we cannot test, with a single maintainer and no downstream users. Where we genuinely need product behavior — decimal vs binary units, precision policy, locale-aware unit labels, and sane handling of 0, null, and extreme values — we should own the logic, because that logic shows up in customer-facing UI and is cheap to build and cheap to test. If a specific legacy service needs a stopgap, pin the version explicitly and isolate it behind our own formatter interface so it can be replaced without touching call sites.
How can I help you explore Laravel packages today?