rych/bytesize
A lightweight PHP package for parsing and formatting byte sizes. Convert human-readable values such as 1.5 MB into bytes and back again, making it useful for file-size validation, storage limits, and user-friendly display.
Architecture fit
rych/bytesize is a leaf-node, single-responsibility utility: it converts an integer byte count into a human-readable string (e.g., 1.18 MB). It has no framework coupling, no I/O, no service container involvement, and no dependencies of its own, so it slots into any PSR-4 autoloaded Laravel application without a service provider or config publish. Architecturally it belongs strictly in the presentation/formatting layer — it must never become the canonical representation of a stored value. The correct pattern is: persist bytes as integers, format at the edge (Blade view, API resource, log line).
Integration feasibility
Composer-installable and MIT-licensed, so legal and tooling friction are both near zero. The real friction is age: the last tagged release is April 2014 (PHP 5.x era), so the composer.json platform constraint is likely permissive-to-the-point-of-meaningless (>=5.3) and the autoload mapping may predate PSR-4 conventions. Feasibility is therefore a one-hour spike, not a project: install on the target PHP (8.2/8.3) and runtime, exercise the API, and confirm no deprecation notices.
Technical risk Blast radius is small and staleness risk is high — an unusual combination worth stating plainly to stakeholders:
1024 B instead of 1 KB, locale decimal separator) surfaces as a cosmetic defect or, worse, a misleading quota/storage figure. It will not throw.Key questions
en_US sufficient?Illuminate\Support\Number::fileSize(), which covers the common case with no third-party dependency.Stack fit
Fits cleanly as a Composer dependency in a Laravel app, but the package should never be referenced directly from controllers or Blade templates. Wrap it behind an application-owned contract (e.g., App\Support\Contracts\ByteFormatter) with a thin adapter. This costs roughly half a day and converts an irreversible dependency into a swappable implementation detail.
Migration path For existing usage: introduce the interface and adapter first, repoint call sites to the container binding, then evaluate replacement in isolation. Because the interface is stable, migrating off the package becomes a single-class change rather than a repo-wide search-and-replace.
Compatibility
Validate against the actual runtime matrix, not assumptions: PHP version, Composer 2 platform checks, and whether the package's autoload declaration still resolves. If PSR-0 only, add a classmap entry rather than patching vendor code. Confirm behavior under the app's locale settings — setlocale can silently alter number formatting.
Sequencing
composer.lock and document the fork/copy contingency.For greenfield work, the default should be the framework helper or ~20 lines of first-party code; adopting a 2014 micro-library requires a specific reason (e.g., needing unusual unit sets or custom suffix formatting).
Maintenance Treat this as internal code, not a dependency. There is no upstream to rely on. Budget a small annual review (PHP version bump, deprecation sweep) and maintain a documented escape hatch: either a vendored copy of the class or a named replacement target. Pinning the exact version and committing the lockfile is mandatory.
Support No vendor, no maintainer, no security advisory feed, no issue triage. This is tolerable precisely because the library has no network, filesystem, deserialization, or authentication surface — the CVE exposure is essentially nil for pure arithmetic. That is the argument that makes an unmaintained package acceptable here, and it should be stated explicitly in the risk register rather than left implicit.
Scaling Non-issue. Formatting is O(1) with trivial memory; even at high request volume the cost is noise compared to framework bootstrap. The only optimization worth noting is not instantiating a formatter object inside tight loops — resolve once, reuse, or statically cache.
Failure modes
The dominant failure mode is wrong output, not errors: off-by-1024 unit boundaries at exactly 1000/1024, rounding that yields 1024 B instead of 1 KB, truncation instead of rounding at the precision boundary, 0 B vs - for null, negative inputs producing nonsense, and locale-driven decimal commas breaking downstream parsers. Because these are silent, the characterization tests from the integration step are the actual control — without them, regressions will be discovered by users looking at a storage dashboard.
Ramp-up Negligible. Any PHP developer understands the component in fifteen minutes, and there is no operational runbook to learn. The genuine cost is governance: a decision record explaining why an abandoned package was adopted (or rejected), plus the wrapper that keeps the exit cheap. The TPM effort here is one evaluation and one decision, not ongoing management.
Recommendation Do not adopt for new development on a modern Laravel baseline — the platform helper covers the requirement with zero dependency risk. Where the package is already in the codebase, contain it behind an interface, pin it, test its output, and schedule replacement. The 0.185 score and 2014 release date are directionally correct: low opportunity, bounded risk, and a clear preference for first-party code.
How can I help you explore Laravel packages today?