jobmetric/laravel-unit
Laravel Unit is a package for working with measurement units in your Laravel app. It helps you define, manage, and convert units with a clean, extendable structure. Lightweight and easy to integrate, useful for storing and displaying quantities consistently.
Architecture fit
jobmetric/laravel-unit is a domain-utility library, not infrastructure: it occupies a narrow seam in the application layer and exposes units of measurement, conversion rules, and formatting. That is architecturally low-risk in the sense that it should not touch routing, auth, or persistence — but unlike a logging or translation helper, it carries business semantics. Two distinct concepts get conflated in most unit packages and the distinction drives the whole evaluation: (a) physical conversion (kg↔lb, m↔ft — a pure function, safe to depend on a library for), and (b) business units (SKU pack sizes, "case of 12", billable hours, packaging tiers) which are policy, not physics, and must remain owned by the application. A TPM's first job here is to decide which of the two the package is being adopted for. If the answer is (a), leverage the library and wrap it. If the answer is (b), do not let a 6-star package become the source of truth for pricing or inventory semantics. The release notes describe only dependency bumps on a companion "core" package, so the package itself appears to be a thin configuration-and-conversion layer over a coupled upstream — meaning its supported behavior is partly determined by a second dependency with its own release cadence.
Integration feasibility
Installation is standard Laravel (composer require, provider auto-discovery, config publish, possibly a migration for a units table). The friction is not installation, it is verification: a unit package can install cleanly and be wrong. Feasibility is gated on answering whether conversion is done with float or decimal arithmetic, what the rounding policy is, and whether non-multiplicative (affine) conversions such as Celsius↔Fahrenheit are supported at all. Each of those is a question the changelog and description do not answer.
Technical risk
| Risk | Severity | Rationale |
|---|---|---|
| Numerical precision / rounding drift | High | Float-based conversion silently produces cents- and gram-level errors that compound across aggregation and reconciliation |
| Affine conversion gaps (temperature, gauge pressure) | High | Multiplicative-only engines return wrong values rather than errors; often undiscovered until production |
| Adoption / abandonment | High | 6 stars, single release track, no visible maintainer model; bus factor of one is the base case |
| Coupled upstream dependency | Medium | A companion "core" package in lockstep means upgrades to one force upgrades to the other |
| Evidence quality | Medium | Changelog is a two-line dependency bump with no API documentation; supporting artifacts describe a different package, so vendor docs cannot be trusted as a spec |
| Silent correctness failure | Medium | Wrong numbers do not throw exceptions; they surface in invoices and inventory counts |
| Framework constraint drift | Low–Medium | Support range for Laravel/PHP is unstated; verify against the target application version |
Key questions
composer.json pinned to a Laravel range compatible with our target?Stack fit
Good for a conventional Laravel application that needs display-layer conversion and consistent measurement formatting in forms and API responses. Poor fit as a system of record for commercial units. The correct posture is port-and-adapter: define an internal interface (e.g. UnitConverter) in application code, implement it with this package, and keep all call sites against the interface. Because the license is MIT, this also preserves the option to vendor the conversion tables and drop the dependency if maintenance lapses — a material de-risking fact for a 6-star package.
Migration path Scope the first integration to a read-only presentation concern, not a persistence concern. Concretely: pick one surface (product weight/dimensions displayed in a user-selected unit system), wire it through the adapter, and leave stored values untouched. Do not begin by converting stored data between units — that is an irreversible data migration and should be a separate, later decision with its own backfill and reconciliation plan. Only after the read path is proven should the team consider using the package's validation rules on input or an Eloquent cast on write.
Compatibility
Two axes. First, framework support: confirm the composer.json constraint against the target Laravel and PHP versions before anything else, and check that the companion core package does not force an unrelated upgrade. Second, boundary compatibility: the unit codes exchanged with clients, ERPs, and carriers (ISO 80000, UN/CEFACT codes) are almost never the package's internal identifiers. Build an explicit mapping table at the API boundary and own it in application config — never let the package's internal unit keys leak into a public contract or a partner integration.
Sequencing
Maintenance Low ongoing change velocity, which cuts both ways: few breaking releases, but also few fixes. Budget a recurring review slot to check the package and its core dependency for releases, and pin exact versions in production rather than floating. The real maintenance burden is internal: someone must own the precision and rounding policy, the unit-code mapping table, and the fixture set. Treat those as application assets, not package configuration.
Support No evidence of a support model, SLA, security disclosure process, or responsive triage. Plan for source-reading as the primary support mechanism and assume the team may need to patch the package itself. MIT licensing makes that legally clean; it does not make it free. Confirm before adoption that at least one engineer is willing to read and, if necessary, fork the conversion tables.
Scaling Conversion is CPU-cheap and will not be a throughput bottleneck. The scaling risk is structural: if unit definitions live in a database table, every conversion or validation path that resolves a unit becomes a query unless the registry is cached — cache the unit registry at boot and warm it as a deploy step. The larger scaling concern is organizational: as more teams consume units, the mapping table and rounding policy become shared contracts and need an owner, versioning, and change review, or you get per-team conventions that fail to reconcile.
Failure modes
kg vs KG vs Kg resolve differently or shadow each other. Mitigation: normalize codes at the boundary.Ramp-up The API surface is small enough that a Laravel developer is productive in under a day. The expensive ramp-up is domain, not package: engineers need the precision policy, the rounding rule, the canonical-storage decision, and the unit-code mapping explained before they write conversion code. Budget a short design note and a shared fixture file as onboarding artifacts. Given the thin documentation and the low adoption signal, assume no institutional knowledge exists outside the team and write it down as you go — that document, not the package, is what makes this maintainable.
How can I help you explore Laravel packages today?