- How do I install Laracash in a Laravel application?
- Install it with Composer using composer require andriichuk/laracash. Laravel auto-discovery registers the service provider, and you can publish the config file if you need to customize currency support. Run your application test suite and check Composer constraints against your Laravel and PHP versions before adopting it broadly.
- Which Laravel and PHP versions does Laracash support?
- Check the package composer.json for the exact Illuminate and PHP constraints, because the last release was May 2024 and may lag current Laravel and PHP versions. Pin the package and add a compatibility test job for every Laravel version you support. If your target version is missing, budget for a fork or replacement.
- Does Laracash require moneyphp/money?
- Laracash is best treated as a Laravel-facing money adapter and value-object layer that likely wraps moneyphp/money rather than a standalone accounting engine. Verify the required moneyphp/money version in Composer before installing. Keep domain code behind an internal wrapper so a future moneyphp upgrade or replacement does not leak into application logic.
- Can I use Laracash with Eloquent models and database money columns?
- Yes, the package is intended to support Eloquent casts and Laravel boundary helpers. Store amounts as integer minor units plus an ISO currency code where feasible, and define null and zero semantics explicitly. Add application tests for cast round-trips and legacy decimal or float conversions before backfilling data.
- How does Laracash handle currency formatting and parsing?
- It provides helpers for formatting, converting, and calculating monetary values, with configurable currency support. Locale-aware input and output and parsing should be tested against your supported locales and frontend expectations. Do not cache formatted display strings for calculations; cache only safe display output.
- Is Laracash suitable for multi-currency accounting, settlement, or FX?
- No, Laracash is a money adapter and value-object layer for Laravel, not a billing, ledger, tax, or FX engine. It can help with currency-safe amount handling, formatting, validation, and casts in monoliths and modular services. Complex multi-currency accounting, settlement, and reconciliation need additional domain modeling and controls.
- How are rounding, allocation, and currency precision handled in Laracash?
- Rounding and precision ultimately follow moneyphp/money conventions exposed through the package, so your application must define an explicit rounding policy. Test allocation and rounding cases with representative currencies and edge values. Keep these rules in a project-owned MoneyService or value-object wrapper rather than scattering them across controllers and Blade templates.
- Does Laracash provide validation rules for monetary input?
- The integration approach includes Laravel validation rules alongside parsing and formatting helpers. Normalize user input at the HTTP boundary, validate currency codes and amount shape, then convert to minor units before persistence. Cover invalid locale formats, nulls, zeros, and negative amounts in tests.
- What are the production risks of using Laracash?
- The package is small, single-maintainer, low-adoption, and had its last release in May 2024, so Laravel and PHP compatibility and maintenance may lag. MIT licensing is favorable, but there is no commercial support. Pin versions, isolate usage behind an internal abstraction, add application tests for money bugs, and keep a fork or replacement contingency plan.
- What alternatives to Laracash should I evaluate?
- Evaluate moneyphp/money directly, brick/money, or a small project-owned money value object with explicit storage and rounding rules. Laracash remains useful as a Laravel boundary adapter for validation, casts, and formatting if it fits your version matrix. Compare maintenance, ext-intl requirements, multi-currency behavior, and test coverage before choosing.