Search by

phil / phone-bundle

phil

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

Homepage

Type:symfony-bundle

pkg:composer/phil/phone-bundle

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

0.1.0-alpha 2026-11-11 04:05 UTC

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.