Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Human Readable File Size Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Feature-level formatting decisions across any surface that shows file weight: upload widgets, attachment lists, media libraries, storage-quota dashboards, admin panels, export/import logs, invoice attachments, and email/PDF receipts.
  • A build-vs-buy call — and here the answer is "build." The entire domain logic is a division plus a unit suffix. That is a decision worth recording once, not a dependency worth carrying forever.
  • A canonical-formatter decision. If we display file sizes in the UI, API responses, emails, and PDFs, they must agree. That argues for one owned helper (or framework-native method), not a third-party package used ad hoc in one controller.
  • A localization decision. If the product ships in non-English locales (Ko/Mo/Go, バイト, locale-specific decimal separators), the formatter becomes a small product concern the team should own outright.
  • Not a roadmap item. It should never appear as a line on a roadmap or consume more than a fraction of a sprint; treat it as table stakes plumbing.

When to Consider This Package

Consider it only when all of the following hold:

  • You are on a PHP/Laravel version that predates Number::fileSize() (Laravel 11+ has this in core).
  • You need a drop-in one-liner today for a prototype, internal tool, or throwaway script.
  • Someone has read the (very small) source and you are comfortable vendoring or pinning it.

Look elsewhere or build in-house when:

  • You are on Laravel 11+. Number::fileSize($bytes, precision: 2) covers this with zero added dependency.
  • You need control. Decimal (KB/MB) vs binary (KiB/MiB), precision rules, rounding behavior, 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.
  • You have dependency-review or supply-chain policy. 5 stars, 0 dependents, last release August 2023, single maintainer, no visible security posture. Zero downstream validation means zero signal that the code is exercised in production anywhere but its author's project. The risk-to-benefit ratio is inverted for a ten-line function.
  • You need a testing or SLA guarantee your organization can point at.

How to Pitch It (Stakeholders)

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.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
takashato/laravel-vietqr
aitor24/laralang
kraenzle-ritter/entity-relations
dindigital/din-image
pomirleanu/image-colors
sawmainek/laravel-api-generator
delatbabel/jsonresponses
mouhamedfd/permissions-generator
eduplus/qr
laravel2580/idehelpers
delatbabel/viewpages
anavel/gettext
muhamadrezaar/highcharts
delatbabel/keylists
frankkessler/salesforce-laravel-oauth2-rest
anavel/foundation
wdmtech/enviricons
eii/laravel-captcha
muka/shape-reader
tdt/json