Search by

zetflake / number-to-words

ntumevicent

Convert numbers and currency amounts to their written English words representation for Laravel.

Package info

github.com/Zetflake/number-to-words

Homepage

pkg:composer/zetflake/number-to-words

Statistics

Installs: 2

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0 2026-09-16 15:05 UTC

This package is auto-updated.

Last update: 2026-09-16 15:22:07 UTC


README

Convert numbers and currency amounts into written English words. Built for the "Amount in words" line on invoices, proformas and receipts.

Uses PHP's ext-intl when available and falls back to a bundled pure PHP speller that produces identical output when it isn't.

Installation

composer require zetflake/number-to-words

The service provider is auto-discovered. Publish the config if you want to change the defaults:

php artisan vendor:publish --tag=number-to-words-config

Usage

use Zetflake\NumberToWords\Facades\NumberToWords;

NumberToWords::convert(1234);
// "One thousand two hundred thirty-four"

NumberToWords::currency(1500.50);
// "One thousand five hundred shillings and fifty cents"

NumberToWords::currency(1500.50, 'dollars', 'cents');
// "One thousand five hundred dollars and fifty cents"

NumberToWords::case('upper')->convert(42);
// "FORTY-TWO"

Or inject it:

use Zetflake\NumberToWords\NumberToWords;

public function __construct(private NumberToWords $words) {}

Or use the helpers:

number_to_words(99);          // "Ninety-nine"
amount_in_words(99.25);       // "Ninety-nine shillings and twenty-five cents"

In Blade:

<p>Amount in words: @amountInWords($invoice->total)</p>
<p>Quantity: @numberToWords($item->quantity)</p>

From the CLI:

php artisan number-to-words 1234
php artisan number-to-words 1234.56 --currency

Notes

  • convert() truncates decimals. Use currency() if you need the fractional part.
  • Negative values are prefixed with "negative" rather than silently made positive.
  • Integers up to quintillions are supported; beyond that the number is returned as-is.
  • Set use_intl to false in the config to guarantee byte-identical output across servers regardless of whether the intl extension is installed.

Testing

composer install
composer test

License

MIT