- How do I install andrey-helldar/digittext in a Laravel application?
- Install the package with Composer using composer require andrey-helldar/digittext. In Laravel, register the package service provider and facade if your Laravel version does not auto-discover them. Then set the locale and precision options required by your application. Confirm the PHP and Laravel version constraints in the package composer.json before rollout.
- Does DigitText include a Laravel service provider and facade?
- Yes, DigitText is described as Laravel-friendly and ships with a service provider and facade. You can use the facade for convenient static access or resolve the underlying service through Laravel's container. The core package is framework-agnostic, so the Laravel integration is optional convenience rather than a hard requirement.
- How do I convert a number into written words with DigitText?
- Pass the numeric value to the package conversion API and specify the locale you want to use. DigitText returns a human-readable string suitable for invoices, receipts, contracts, and similar documents. Configure precision, currency, and decimal behavior before generating production output. Check the package documentation for exact method names and examples for your installed version.
- Can DigitText convert words back into numbers?
- Yes, DigitText supports two-way conversion between digits and text. The text-to-number path is useful when parsing user input, imported documents, or stored written amounts. Validate the locale and fractional-part handling for your specific use case. Test edge cases such as zero, negatives, and large values before relying on it in production.
- How do I add or customize a language locale in DigitText?
- DigitText ships with multiple language packs and supports extensible locales. You can add or customize locale rules according to the package documentation, then verify grouping, decimal separators, currency wording, and fractional parts. If German output matters, validate de_DE carefully because release notes describe the German localization fix as an attempt. Include locale-specific examples in your test suite.
- Does DigitText handle currency and decimal formatting?
- Yes, DigitText handles currency and decimal formatting as part of converting numbers into readable text. Configure precision and fractional-part behavior to match your invoice, receipt, or legal-document requirements. Be aware that patch releases can change rendered strings for zero values, grouping, and fractional precision. Treat formatted output as a compatibility surface and test it before upgrading.
- Which Laravel and PHP versions are supported by DigitText?
- The exact supported Laravel and PHP versions are not specified in the provided context, so check the package composer.json and release notes. Validate compatibility against your application's Laravel version, especially if you run an older LTS release. Pin the package version in composer.json and run CI before deploying. This avoids unexpected dependency conflicts during rollout.
- How should I test number-to-words output in a Laravel application?
- Use PHPUnit or your existing test suite to cover supported locales and edge cases such as zero, zero with a fractional part, negative values, large numbers, grouping, and varying precision. Add snapshot or golden-master tests for invoice, PDF, API, and UI strings that consume formatted numbers. Test de_DE and en_US explicitly when those locales matter. Manually review locale-specific output where automated coverage is uncertain.
- Can I use DigitText outside of Laravel?
- Yes, the core is described as lightweight and framework-agnostic, so it can be used in any PHP project through Composer autoloading. The Laravel service provider and facade are optional integration points. You still need to configure locale and precision explicitly in non-Laravel environments. Keep the same regression tests for formatted output regardless of framework.
- What should I check before upgrading DigitText within the 5.0.x line?
- Review the 5.0.2 changes that affect first-group display, fractional precision, zero-with-fraction rendering, lost fractional digits, German localization, and removed license blocks. Pin 5.0.2, inspect the diff and changelog for undocumented small fixes, and run formatting regression tests across locales. Have legal review the license-header removal even if the root LICENSE file remains. Deploy through staging or canary with a rollback plan because formatted strings may change.