phil / phone-bundle
phil/phone in Symfony: a phone number field read in a default country, the constraint ValidPhoneNumber with accepted types and countries, the column type phil_phone, and numbers in Twig
Package info
github.com/parler-haut-interagir-librement/phone-bundle
Type:symfony-bundle
pkg:composer/phil/phone-bundle
Requires
- php: >=8.5
- phil/phone: ^0.1@dev
- symfony/config: ^8.2
- symfony/dependency-injection: ^8.2
- symfony/form: ^8.2
- symfony/options-resolver: ^8.2
- symfony/validator: ^8.2
Requires (Dev)
- ext-intl: *
- doctrine/dbal: ^4.5
- doctrine/doctrine-bundle: ^3.3
- doctrine/orm: ^3.7
- phpunit/phpunit: ^13.4
- psr/log: ^3.0
- symfony/event-dispatcher: ^8.2
- symfony/framework-bundle: ^8.2
- symfony/http-kernel: ^8.2
- symfony/translation: ^8.2
- symfony/twig-bridge: ^8.2
- symfony/twig-bundle: ^8.2
- twig/twig: ^3.21
Suggests
- doctrine/dbal: For the phil_phone column type
- twig/twig: For the phone and phone_link filters
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-11-11 06:16:33 UTC
README
A phone number field, a validation constraint, a column type and Twig filters for Symfony.
phil/phone-bundle brings phil/phone into a Symfony application. PhoneType is a tel field that reads a number
typed without its country code in a default country, the bundle's default_region unless the field names its own.
It refuses a number in no numbering plan, and shows a number of its country nationally and any other
internationally. The constraint ValidPhoneNumber accepts a valid number of the types and countries it names, all of
them by default. With DoctrineBundle, the column type phil_phone stores a number in E.164 with its extension, and
Twig gets the filters phone and phone_link. Messages come in English and French.
It is for Symfony applications whose forms collect phone numbers: a member's mobile, a shop's line, a contact at an organisation. The default country lets people type numbers as they write them at home. The constraint lets a form ask for a mobile only, or for a number from Canada or the United States only.
Use phil/phone directly outside Symfony or inside a domain model. The bundle holds no numbering rule: parsing,
validation and formatting are the library's, and the bundle wires them into Symfony Form, Validator, Doctrine DBAL
and Twig.
Status
| Part | State |
|---|---|
PhoneType: a number typed with or without its country code, refused when in no plan |
Implemented and tested |
ValidPhoneNumber: a valid number, of accepted types and countries |
Implemented and tested |
The column type phil_phone |
Implemented and tested |
Twig: phone, phone_link |
Implemented and tested |
| Messages in English and French | Implemented and tested |
Documentation
| Document | What it covers |
|---|---|
| Installation | Requirements, installing, registering, default_region. |
| Forms and validation | PhoneType and ValidPhoneNumber. |
| Doctrine | The column type phil_phone. |
| Twig | The two filters. |
| Extension points | What an application implements, configures, replaces or relies on. |
| Testing | How the bundle is tested. |
| Reference | Every type of the bundle. |
Quick start
composer require phil/phone-bundle
# config/packages/phil_phone.yaml phil_phone: default_region: CA
$builder->add('phone', PhoneType::class);
{% set link = shop.phone|phone_link %}
{% if link %}<a href="{{ link }}">{{ shop.phone|phone('national') }}</a>{% endif %}
Requirements
PHP 8.5 or later; phil/phone 0.1; symfony/config, symfony/dependency-injection, symfony/form,
symfony/options-resolver and symfony/validator 8.2 or later. Doctrine DBAL and Twig are optional.
Contributing
Contributions are welcome on the PHIL monorepo: read the contribution guide and the code of conduct. Report a vulnerability privately, as the security policy explains, never in a public issue.
License
MIT, © Philippe Gamache, doing business as Le Gnome Archiviste; a Parler Haut Interagir Librement project. See LICENSE.