- How do I install litipk/php-bignumbers in a Laravel app?
- Run composer require litipk/php-bignumbers. There is no service provider, facade, config file, or migration to publish, so installation is just the Composer package and PSR-4 autoloading. You can use the BigInteger, BigDecimal, and BigRational classes directly in domain services or DTOs.
- Does litipk/php-bignumbers support Laravel 10 and Laravel 11?
- The package is framework-agnostic and has no Laravel-specific integration, so Laravel version support depends on whether the library runs on your PHP version rather than on Laravel itself. It was last released in 2017 for PHP 7.0-era code, so test it on your target PHP runtime. On PHP 8.1 and later expect deprecation notices, and on a future PHP major expect possible breakage with no upstream fix.
- Which backend does it use for big number math, GMP, BCMath, or pure PHP?
- It uses a pluggable arithmetic provider and can work with GMP, BCMath, or a pure-PHP fallback. GMP and BCMath are much faster, but they must be installed in every runtime: local dev, CI, container images, queue workers, and scheduled jobs. The pure-PHP fallback removes the extension dependency at a performance cost.
- How do I persist BigDecimal values with Eloquent without losing precision?
- There is no first-party Eloquent cast, so write a custom cast that stores the value as a string or a decimal/string database column and never as a float. Define one serialization contract for database columns, queues, and JSON APIs so values round-trip exactly. Keep the cast in your application layer so the domain stays independent of the package.
- Is litipk/php-bignumbers maintained and safe for production?
- No, the repository is archived and the final release is dated 2017-08-31, with no maintainer, security disclosure process, or release cadence. The MIT license is the main mitigation because it lets you vendor or fork the code and patch it yourself. For new production work, prefer a maintained alternative or budget for owning a fork.
- Can I use it for money and currency calculations in Laravel?
- Yes, it can perform exact integer and decimal arithmetic for billing, invoicing, tax, and currency conversion without floating-point loss. Before adopting it, confirm that its scale and rounding behavior matches your accounting policy, including tie-breaking and banker's rounding if required. If your domain only needs fixed-scale cents, integer arithmetic may be simpler than a big-number library.
- How does litipk/php-bignumbers compare with brick/math or phpseclib BigInteger?
- They solve the same problem with immutable big-number value objects, but brick/math is actively maintained and is often the more practical choice for modern Laravel applications. phpseclib BigInteger is also maintained and widely used. litipk/php-bignumbers is archived, so its main advantage is a simple API and low coupling, not long-term support.
- Why do I see deprecation warnings on PHP 8.1, 8.2, or 8.3 with this package?
- The code predates modern PHP type declarations and uses implicit nullable parameters and other patterns that trigger deprecations on PHP 8.1 and later. There is no upstream maintainer to fix them. You can suppress or baseline the notices, but for production you should either fork and patch the code or choose a maintained library.
- How do I test code that uses litipk/php-bignumbers in Laravel?
- Use normal PHPUnit feature or unit tests around your domain services and assert with the package's comparison methods rather than PHP's equality operators. Because values are immutable, you can safely reuse fixtures and expected values. The package has in-repo tests but its CI is inactive, so add your own characterization tests on the PHP versions and arithmetic backends you deploy.
- Can litipk/php-bignumbers run without the GMP or BCMath PHP extension?
- Yes, it includes a pure-PHP arithmetic fallback, so the package can run on hosts without GMP or BCMath. Performance will be significantly worse for heavy calculations, which matters in request paths, queue workers, and batch jobs. For predictable production behavior, treat the chosen backend as an environment contract and verify it in CI and deployment images.