neophp / locale-package
Static country and currency data with formatting helpers for NeoPHP
Requires
- php: >=8.5
README
Static country and currency reference data for NeoPHP, with a currency formatting Twig filter. No external API, no network dependency.
Structure
locale-package/
├── composer.json
├── README.md
└── src/
├── NeoLocalePackage.php
├── Data/
│ ├── CountryList.php
│ └── CurrencyList.php
├── Service/
│ ├── CountryProvider.php
│ └── CurrencyFormatter.php
└── Extension/
└── LocaleViewExtension.php
How it works
CountryList and CurrencyList are static datasets (~29 countries,
~19 currencies) — a curated starting set, not the full ISO 3166-1/4217
lists. CountryProvider and CurrencyFormatter expose them through
simple services, and LocaleViewExtension makes them available directly
in Twig as countries(), currencies(), and a format_currency filter.
No IP-based country detection and no live currency conversion — this package only provides reference data and formatting, nothing that requires a network call.
Installation
Published (Packagist)
composer require neophp/locale-package
Via package:require
php bin/neo package:require neophp/locale-package --project=MyProject
Local development (path repository)
Root composer.json of the NeoPHP framework:
{
"repositories": [
{ "type": "path", "url": "packages/locale-package" }
]
}
Target project's composer.json:
{
"require": {
"neophp/locale-package": "@dev"
}
}
composer update
Enabling the package
// src/MyProject/Config/app.config.php return [ // ... 'packages' => [ \Vendor\NeoPHP\LocalePackage\NeoLocalePackage::class, ], ];
No configuration file — there is nothing to customize per project.
Usage
Country select
<select name="country"> {% for code, country in countries() %} <option value="{{ code }}">{{ country.name }}</option> {% endfor %} </select>
Currency select
<select name="currency"> {% for code, currency in currencies() %} <option value="{{ code }}">{{ currency.name }} ({{ currency.symbol }})</option> {% endfor %} </select>
Formatting a price
{{ 1234.5|format_currency('EUR', 'fr') }}
{# → 1 234,50 € #}
{{ 99.9|format_currency('USD') }}
{# → $99.90 #}
In PHP
use Vendor\NeoPHP\LocalePackage\Service\CountryProvider; use Vendor\NeoPHP\LocalePackage\Service\CurrencyFormatter; $countryProvider->find('FR'); // ['name' => 'France', 'dialCode' => '+33', 'currency' => 'EUR'] $currencyFormatter->format(1234.5, 'EUR', 'fr'); // '1 234,50 €'
License
MIT