PHPackages                             ydee/phone-number-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Validation &amp; Sanitization](/categories/validation)
4. /
5. ydee/phone-number-bundle

ActiveSymfony-bundle[Validation &amp; Sanitization](/categories/validation)

ydee/phone-number-bundle
========================

Symfony 6.4+ bundle for robust phone number validation and formatting, powered by libphonenumber.

00PHP

Since Jul 4Pushed 12mo agoCompare

[ Source](https://github.com/yaovicoder/phone-number-bundle)[ Packagist](https://packagist.org/packages/ydee/phone-number-bundle)[ RSS](/packages/ydee-phone-number-bundle/feed)WikiDiscussions main Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

Ydee PhoneNumberBundle
======================

[](#ydee-phonenumberbundle)

Symfony 6.4+ bundle for robust phone number validation and formatting, powered by [libphonenumber](https://github.com/giggsey/libphonenumber-for-php).

Features
--------

[](#features)

- Phone number validation for Symfony forms and Doctrine entities
- Region-aware validation (optional)
- Inspired by misd/phone-number-bundle, but fully compatible with Symfony 6.4+

Installation
------------

[](#installation)

```

```

Usage
-----

[](#usage)

### 1. Enable the bundle (if not using Symfony Flex)

[](#1-enable-the-bundle-if-not-using-symfony-flex)

```
// config/bundles.php
return [
    // ...
    Ydee\PhoneNumberBundle\PhoneNumberBundle::class => ['all' => true],
];
```

### 2. Add the constraint to your entity or form

[](#2-add-the-constraint-to-your-entity-or-form)

```
use Ydee\PhoneNumberBundle\Validator\Constraints\PhoneNumber;

class User
{
    #[PhoneNumber(region: 'FR', message: 'Please enter a valid French phone number.')]
    private ?string $phone = null;
}
```

### 3. Customizing

[](#3-customizing)

- The `region` option is optional. If omitted, parsing will be international.
- The default error message is: `This value is not a valid phone number.`

Translation
-----------

[](#translation)

The default error message can be translated using Symfony's translation component. Add the following to your translation files (e.g., `validators.en.yaml`):

```
Ydee\PhoneNumberBundle\Validator\Constraints\PhoneNumber:
    This value is not a valid phone number.: 'Your custom message here.'
```

Future Extensions
-----------------

[](#future-extensions)

You may add a phone number formatting service to provide consistent output formatting using libphonenumber. If you need this, open an issue or contribute!

Symfony Flex Recipe
-------------------

[](#symfony-flex-recipe)

For easier installation, consider contributing a Symfony Flex recipe to enable auto-registration of the bundle.

Contributing
------------

[](#contributing)

Contributions are welcome! Please submit pull requests or open issues for bugs, features, or improvements.

License
-------

[](#license)

MIT +Copyright (c) 2025 Yaovi + +## Support + +For support, please open an issue on the repository or contact the author at .

Changelog
---------

[](#changelog)

See [CHANGELOG.md](CHANGELOG.md) for version history and updates.

Running Tests
-------------

[](#running-tests)

To run the test suite:

```
composer install
vendor/bin/phpunit

```

###  Health Score

14

—

LowBetter than 1% of packages

Maintenance37

Infrequent updates — may be unmaintained

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity14

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2089260?v=4)[Yaovi](/maintainers/yaovicoder)[@yaovicoder](https://github.com/yaovicoder)

---

Top Contributors

[![yaovicoder](https://avatars.githubusercontent.com/u/2089260?v=4)](https://github.com/yaovicoder "yaovicoder (4 commits)")

### Embed Badge

![Health badge](/badges/ydee-phone-number-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/ydee-phone-number-bundle/health.svg)](https://phpackages.com/packages/ydee-phone-number-bundle)
```

###  Alternatives

[marcosh/php-validation-dsl

A DSL for validating data in a functional fashion

483.9k](/packages/marcosh-php-validation-dsl)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
