Download the PHP package pinoox/numera without Composer

On this page you can find all versions of the php package pinoox/numera. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package numera

Numera: A PHP Library for Number to Words Conversion

Coverage Latest Stable Version GitHub Stars GitHub Forks GitHub Issues License Total Downloads

Numera is a PHP library that converts numbers to words (and back), with support for 184 ISO 639-1 languages, regional variants, ordinals, currency, units, weekdays, cross-locale translation, and specialized reading modes (fractions, years, phone numbers, Roman numerals, IP/version strings).

Requirements: PHP ^8.0, Composer. No runtime dependencies.

Quick start:

Install (plain PHP): composer require pinoox/numera — see CHANGELOG.md for release notes.

Using Laravel? Go to For Laravel users — install pinoox/numera-laravel only.

Features

API reference

Method Alias Description
n2w($num) — Number → words (supports multiple input formats)
w2n($words) s2n Words → number
n2s($num) — Number → summary (e.g. 4 Billion, 454 Million)
toOrdinal($n) n2o Ordinal words
toCurrency($amount, $code) — Money with main/sub units
withUnit($n, $unit) — Amount + unit (kg, hour, …)
toWeekday($day) d2w ISO key, index, or name → weekday word
getWeekdays() — All weekdays (order from meta.week_starts_on)
translateTo($locale, $words) t2t Cross-locale word translation
detectFormat($input) — Static: default, european, swiss, persian, underscore
toFraction($float) n2f Common fractions (half, quarter, …)
toYear($year) n2y Year reading (English pairs; else cardinal)
toPhone($string) n2p Phone digit-by-digit
toRoman($int) n2r Integer → Roman (1–3999)
fromRoman($roman) — Static: Roman → integer
toIp($ipv4) n2ip IPv4 octets as words
toVersion($semver) — Version string (digits + labels)
setLocale($code) — Switch locale (loads src/lang/{code}.php)
setLocaleFallback($code) — Fallback when a key is missing
setCamelCase($bool) — Title-case output

Static helpers: Numera::init($locale, $fallback), getAvailableLocales(), hasLocale($code).

Project layout

For Laravel users

Use the dedicated Laravel package — it pulls in pinoox/numera automatically.

Install

Requirement Version
PHP ^8.0
Laravel 9, 10, or 11
Packagist pinoox/numera-laravel

No manual service-provider registration: Laravel auto-discovers NumeraServiceProvider and registers the Numera facade.

Configuration (required once)

Edit config/numera.php:

Usage

All methods from the core library (n2w, w2n, toCurrency, toFraction, …) work on the facade.

More detail

Installation and Setup

Note: This section is for plain PHP (Symfony, WordPress, custom apps). Laravel projects should follow For Laravel users above.

Install via Composer

You can install Numera using Composer:

Initialize Numera

To use Numera, you need to initialize it with a locale. You can do this using the init method:

Convert Numbers to Words

To convert a number to words, use the convertToWords method:

Alternatively, you can use the n2w method for a simpler syntax:

Negative Numbers

Decimal Numbers

Each digit after the decimal separator is read individually. Accepts floats or strings (3.14, 1,250.75).

Ordinal Numbers

Currency Formatting

Supported codes: USD, EUR, GBP, IRR, IRT (extend via language file currencies maps).

Units

Supported units: kg, g, km, m, cm, hour, minute, second, day, week, month, year.

Weekdays

Day names live in each language file under weekdays (monday … sunday). Use ISO weekday numbers (1 = Monday … 7 = Sunday), PHP date('w') (0 = Sunday … 6 = Saturday), or the English key name.

Optional meta.week_starts_on in src/lang/{locale}.php controls the order returned by getWeekdays() (default: monday).

Cross-locale translation (words → words)

Convert spoken/written text in one language to another via a neutral intermediate (integer or weekday key):

Supports cardinal numbers (including negative and decimal phrases), and weekday names. Currency/unit phrases are not converted yet.

Chain with locale and camel case:

Convert Numbers to Summary

To convert a number to summary words, use the convertToSummary method:

Alternatively, you can use the n2w method for a simpler syntax:

Convert Words to Numbers

To convert words to a number, use the convertToNumber method:

Alternatively, you can use the w2n method for a simpler syntax:

You can also specify separators for the w2n method:

Use Camel Case

To use camel case for output words, use the setCamelCase method:

Input Formats

n2w() and w2n() normalize these string formats before parsing:

Format Example detectFormat()
Default 1234.56, 1,250.75 default
European 1.234.567,89 european
Swiss 1'234'567.89 swiss
Persian/Arabic digits ۱۲۳۴ persian
Underscore 1_000_000 underscore

Fractions

Years

English uses paired year reading (1999 → nineteen ninety-nine). Other locales use cardinal form.

Phone Numbers

Reads digit-by-digit with locale-aware digit words.

Roman Numerals

IP and Version Strings

Supported Languages

Numera ships with 184 ISO 639-1 language packs under src/lang/, plus regional variants such as en-US, en-GB, fa-IR, de-DE (see src/data/regional-locales.php). Each base file contains cardinals, separators, and v1.2 keys (negative, point, ordinals, currencies, units, weekdays, …). Edit the locale file directly — see src/lang/en.php and TranslationGuide.md.

Regional variants (BCP 47): Files like src/lang/en-US.php only declare overrides (usually meta.region); translations are merged from the parent (en.php → en-US.php). Configured regions are listed in src/data/regional-locales.php.

Number strategies: Languages with special compounding use meta.strategy in the lang file (see src/data/locale-strategies.php):

Strategy Locales Reason
german de, de-* Inverted tens (einundzwanzig), tausend concatenation
french fr, fr-* Vigesimal 70–99 (soixante-dix, quatre-vingts)
multiplier_tens id, ms, vi, jv, tl, mi, sm, to, ty dua puluh tiga = 2×10+3, not 2+10+3
default Most others English-style place value

Welsh (cy), Breton (br), and some locales with incomplete lang data may still need dedicated strategies or richer translations in src/lang/.

Set Locale

To set the locale for the Numera object, use the setLocale method:

Set Locale Fallback

To set the fallback locale for the Numera object, use the setLocaleFallback method:

Get Translates

To get the translates for the current locale, use the getTranslates method:

Add Translate

To add translates for a specific locale, use the addTranslate method:

Add Translate File

To add translates by array file for a specific locale, use the addTranslateFile method:

Create a New Language

If you want to add support for a new language, please read our Translation Guide for a step-by-step guide on how to create a new language pack.

Author

Numera was created by Pinoox.

Contributing

If you'd like to contribute to Numera, please fork the repository and submit a pull request. We'd love to have your help.

Testing

Laravel package CI runs in pinoox/numera-laravel.

CI for this library runs on push/PR to master (see .github/workflows/ci.yml).

Upgrade from 2.0

New methods are additive; existing n2w, w2n, toCurrency, etc. are unchanged. Add fractions, plus, dot, dash to custom lang files if you use toFraction, toPhone, toIp, or toVersion.

Documentation

License

Numera is licensed under the MIT License. See the LICENSE file for more information.


All versions of numera with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package pinoox/numera contains the following files

Loading the files please wait ...