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 10mo 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 1mo ago

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

15

—

LowBetter than 3% of packages

Maintenance39

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://www.gravatar.com/avatar/6c7ae1b5ebb8742a52176a7647f12f58680fa236427fee6df208be3fd02b00d3?d=identicon)[yaovicoder](/maintainers/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

[webmozart/assert

Assertions to validate method input/output with nice error messages.

7.6k894.0M1.2k](/packages/webmozart-assert)[bensampo/laravel-enum

Simple, extensible and powerful enumeration implementation for Laravel.

2.0k15.9M104](/packages/bensampo-laravel-enum)[swaggest/json-schema

High definition PHP structures with JSON-schema based validation

48612.5M73](/packages/swaggest-json-schema)[stevebauman/purify

An HTML Purifier / Sanitizer for Laravel

5325.6M19](/packages/stevebauman-purify)[ashallendesign/laravel-config-validator

A package for validating your Laravel app's config.

217905.3k5](/packages/ashallendesign-laravel-config-validator)[crazybooot/base64-validation

Laravel validators for base64 encoded files

1341.9M8](/packages/crazybooot-base64-validation)

PHPackages © 2026

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