Download the PHP package alexivanou/russian-text-bundle without Composer
On this page you can find all versions of the php package alexivanou/russian-text-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download alexivanou/russian-text-bundle
More information about alexivanou/russian-text-bundle
Files in alexivanou/russian-text-bundle
Package russian-text-bundle
Short Description Symfony bundle providing Russian text functions: pluralization, number spelling, name inflection, noun/adjective declension, money spelling, time intervals, and more. Wraps wapmorgan/morphos into Symfony DI services and Twig extensions.
License MIT
Informations about the package russian-text-bundle
RussianTextBundle
Symfony bundle providing Russian text functions: pluralization, number spelling, name inflection, noun/adjective declension, geographical name inflection, money spelling, time ago, transliteration, phone formatting, identifier validation, semantic name parsing, date formatting, and text utilities. Built on top of wapmorgan/morphos.
Also available in Russian.
Installation
Symfony Flex will auto-configure the bundle. If you don't use Flex, add to bundles.php:
Configuration
Every feature can be toggled on or off. When a feature is disabled, its service definition and autowiring alias are removed from the container at compile time — they are never instantiated, never loaded, and never consume memory.
All flags default to true.
Why this matters
Memory savings
Every service is a container object with its own definition, arguments, and tags. Even if a service is never invoked, its definition is loaded into memory during DI container compilation. Disabling unused services:
- Reduces compiled container size (files in
var/cache/{env}/Container*.php) - Lowers PHP memory consumption per request in production
- Removes autowiring aliases, speeding up dependency resolution
Performance
On each Symfony request the container goes through several compilation phases:
- Resolution — resolving all service arguments. Fewer services = faster resolution.
- Dump — writing the compiled container to disk (only on first request after cache clear).
- Autowiring — searching for a matching service by type. Aliases for disabled services are not registered → faster autowiring.
Real-world example
If you only use Pluralizer and TimeSpeller (no validators, phones, declensions), disabling 15+ flags removes ~20 class definitions + 12 autowiring aliases from the container. Difference in a typical Symfony project:
| Metric | All enabled | Minimal set |
|---|---|---|
| Lines of compiled container code | ~3000 | ~800 |
| Service definitions | ~40 | ~18 |
| Memory per request | ~2.8 MB | ~2.5 MB |
| Compilation time (debug=0) | ~120 ms | ~80 ms |
Values are approximate and depend on PHP version and project complexity.
How it works
Flags are honest: if enable_pluralizer: false, then:
- Service
alexivanou.russian_text.pluralizeris NOT registered - Autowiring alias
PluralizerInterface::classis NOT registered - Any attempt to inject
PluralizerInterfacethrows a clearServiceNotFoundException, not a silent null
This lets IDEs and static analyzers (PHPStan, Psalm) correctly track dependencies.
Services
| Service ID | Interface | Description |
|---|---|---|
alexivanou.russian_text.pluralizer |
PluralizerInterface |
Pluralization of nouns after numerals |
alexivanou.russian_text.number_speller |
NumberSpellerInterface |
Cardinal and ordinal numerals in words |
alexivanou.russian_text.money_speller |
MoneySpellerInterface |
Money amounts in words (RUB, USD, EUR, UAH, KZT, BYN) |
alexivanou.russian_text.name_inflector |
NameInflectorInterface |
Personal name inflection by cases + gender detection |
alexivanou.russian_text.noun_decliner |
NounDeclinerInterface |
Noun declension by cases + pluralization |
alexivanou.russian_text.adjective_decliner |
AdjectiveDeclinerInterface |
Adjective declension by cases, gender, number |
alexivanou.russian_text.geo_inflector |
GeographicalNameInflectorInterface |
Geographical name inflection by cases |
alexivanou.russian_text.time_speller |
TimeSpellerInterface |
Human-readable time intervals in Russian |
alexivanou.russian_text.transliterator |
TransliteratorInterface |
Cyrillic → Latin transliteration + slug |
alexivanou.russian_text.identifier_validator |
IdentifierValidatorInterface |
INN, SNILS, OGRN, SWIFT, IBAN, etc. validation |
alexivanou.russian_text.phone_formatter |
PhoneFormatterInterface |
Phone number formatting (30 countries) |
alexivanou.russian_text.name_parser |
NameParserInterface |
Semantic FIO parsing |
alexivanou.russian_text.russian_date_formatter |
RussianDateFormatterInterface |
Russian month/day names |
alexivanou.russian_text.text_helper |
TextHelperInterface |
ordinalSuffix, currencySymbol, truncate |
Twig Usage
Pluralization (pluralize filter)
Number spelling (cardinal, ordinal filters)
Money spelling (spell_money filter)
Name inflection (inflect_name filter, name_cases, detect_gender functions)
Noun declension (noun_case, noun_plural filters)
Adjective declension (adj_case filter)
Geographical name inflection (geo_case filter)
Time ago (time_ago, distance_of_time filters)
Transliteration (translit, slug filters)
Validation functions
Phone formatting
Name parsing
Date formatting
Text helpers
Case Names
All case-aware methods accept any of the following formats:
| Constant | Russian | Abbreviation | English |
|---|---|---|---|
nominative |
именительный | и | nominative |
genitive |
родительный | р | genitive |
dative |
дательный | д | dative |
accusative |
винительный | в | accusative |
ablative |
творительный | т | instrumental |
prepositional |
предложный | п | prepositional |
PHP Usage
Architecture
Services are split into separate classes (not one monolithic helper) so you can inject only what you need.
Each service implements a corresponding interface (PluralizerInterface, NumberSpellerInterface, etc.) and is registered with an autowiring alias. You can type-hint the interface in your constructors:
Validator architecture
The IdentifierValidator uses tagged services. Each validation rule (INN, KPP, SWIFT, IBAN, etc.) is a separate class implementing ValidationRuleInterface tagged with russian_text.validator. To add a custom validator:
The IdentifierValidator collects all tagged validators via a compiler pass and exposes them through the fluent API.
Twig extensions
Twig extensions are separated by domain:
- PluralExtension — pluralization (
pluralize) - NumeralExtension — numerals + money (
cardinal,ordinal,spell_money) - NameExtension — names (
inflect_name,name_cases,detect_gender) - DeclensionExtension — nouns (
noun_case,noun_plural), adjectives (adj_case), geographical names (geo_case) - TimeExtension — time (
time_ago,distance_of_time) - UtilityExtension — transliteration (
translit,slug), text helper (truncate,ordinal_suffix,currency_symbol), date (russian_date,russian_date_genitive,russian_month,russian_day_of_week) - ValidationExtension — phone format (
phone_format,phone_is_valid,phone_detect_country), identifier validation (is_valid_inn,is_valid_snils, etc.), name parsing (parse_name,name_initials)
This design lets you disable unused features via bundle configuration and keeps your DI container lean.
What's covered vs wapmorgan/morphos
| Feature | morphos | This bundle |
|---|---|---|
| Noun pluralization | ✅ Russian\Plurality |
✅ Pluralizer |
| Cardinal numerals | ✅ Russian\CardinalNumeral |
✅ NumberSpeller |
| Ordinal numerals | ✅ Russian\OrdinalNumeral |
✅ NumberSpeller |
| Noun declension | ✅ Russian\GeneralDeclension |
✅ NounDecliner |
| Name inflection | ✅ Russian\name() |
✅ NameInflector |
| Gender detection | ✅ Russian\detectGender() |
✅ NameInflector |
| Adjective declension | ❌ | ✅ AdjectiveDecliner (custom) |
| Geographical name inflection | ❌ | ✅ GeographicalNameInflector (custom) |
| Money spelling | ❌ | ✅ MoneySpeller (custom) |
| Time ago | ❌ | ✅ TimeSpeller (custom) |
Requirements
- PHP 7.2+
- Symfony 4.2+
- Twig 2.0+
- ext-mbstring
Testing
License
MIT
All versions of russian-text-bundle with dependencies
wapmorgan/morphos Version ^2.0
symfony/framework-bundle Version ^4.2 || ^5.0 || ^6.0 || ^7.0 || ^8.0
symfony/twig-bundle Version ^4.2 || ^5.0 || ^6.0 || ^7.0 || ^8.0
twig/twig Version ^2.0 || ^3.0