michael-rubel/laravel-formatters
Laravel Formatters provides a clean, extensible set of formatter classes for common tasks like money, phone numbers, names, dates, and more. Formatters auto-resolve through the container and support method chaining, making consistent formatting simple throughout your app.
Architecture fit
->toArray() overrides, and Blade/JSON formatting logic across models and controllers. The pattern centralizes that logic behind a class per model (or per context), which is a real consistency win in apps with many small resources.spatie/laravel-data, or view models. Adopting a second presentation abstraction creates a "which layer formats this?" ambiguity that outweighs the convenience.Integration feasibility
^x.Technical risk
auth()/now() become non-deterministic and untestable. This is a code-discipline risk introduced by the pattern, not by the package.Dependents: 0 suggests limited field validation — treat the repo's tests as the primary evidence of behavior.Key questions
laravel-data? If yes, is a second formatter layer defensible?Stack fit
composer.json against our version). Zero infrastructure footprint: no queue, cache, storage, or HTTP surface. It composes with Eloquent, Blade, and API Resources rather than competing with them for runtime.app/Formatters/ (or per-domain app/Domain/{X}/Formatters/), with formatters resolved only at the edges — controllers, resources, Blade components — never inside domain services or jobs.Migration path
Product or Invoice with 8–12 derived display fields) and implement a formatter alongside the existing accessors behind a feature flag or simply unused-but-tested.now() without injection), and the exit plan (internal Formatter base class mirroring the package API).Compatibility
strict_types, return-type, and readonly conventions in the package versus our static analysis (PHPStan/Larastan) level — a mismatch here creates noise across every formatter.Sequencing
Maintenance
Support
Scaling
Failure modes
auth()/now()/config reads inside formatters producing non-deterministic output and flaky tests; mitigated by purity rules and injected clock/context.Ramp-up
How can I help you explore Laravel packages today?