PHPackages                             m-adamski/symfony-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. [Utility &amp; Helpers](/categories/utility)
4. /
5. m-adamski/symfony-phone-number-bundle

ActiveSymfony-bundle[Utility &amp; Helpers](/categories/utility)

m-adamski/symfony-phone-number-bundle
=====================================

Bundle for Symfony which integrates with the libphonenumber library

4.0.1(5mo ago)310.4k↓29.2%2MITPHPPHP &gt;=8.2

Since Nov 19Pushed 5mo agoCompare

[ Source](https://github.com/m-adamski/symfony-phone-number-bundle)[ Packagist](https://packagist.org/packages/m-adamski/symfony-phone-number-bundle)[ RSS](/packages/m-adamski-symfony-phone-number-bundle/feed)WikiDiscussions 4.0 Synced 1mo ago

READMEChangelog (10)Dependencies (7)Versions (16)Used By (0)

PhoneNumber Bundle for Symfony
==============================

[](#phonenumber-bundle-for-symfony)

Custom PhoneNumber Bundle integrating [libphonenumber](https://github.com/giggsey/libphonenumber-for-php) library into Symfony project. This bundle is inspired by [PhoneNumberBundle](https://github.com/misd-service-development/phone-number-bundle) but simplified and created for own projects.

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

[](#installation)

Use Composer to install this bundle into Symfony project:

```
composer require m-adamski/symfony-phone-number-bundle

```

Configuration
-------------

[](#configuration)

This Bundle provide type template for Bootstrap 5. Register it in `config/packages/twig.yaml`

```
twig:
    form_themes:
        - '@PhoneNumber/Form/phone_number_bootstrap_5.html.twig'
```

How to use it?
--------------

[](#how-to-use-it)

Bundle provide additional Doctrine Type and Form Type. First, edit entity to use PhoneNumber Type:

An additional Doctrine Type has been removed from the bundle, because its use caused a problem with logging changes to the entity. Phone number is now stored in the database as string.

```
use Adamski\Symfony\PhoneNumberBundle\Validator as AssertPhoneNumber;

#[AssertPhoneNumber\PhoneNumber]
#[ORM\Column(type: "string", nullable: true)]
protected ?string $phoneNumber;
```

Now it's time to provide changes in Form Type:

```
use Adamski\Symfony\PhoneNumberBundle\Form\PhoneNumberType;

public function buildForm(FormBuilderInterface $builder, array $options) {
    $builder->add("phoneNumber", PhoneNumberType::class, [
        "label"       => "Phone number",
        "preferred"   => "PL",
        "countries_renderer" => function ($countryName, $countryCode, $regionCode) {
            return sprintf("%s (+%d)", $countryName, $countryCode);
        },
        "number_attr" => ["placeholder" => "e.g. 123 123 123"],
        "required"    => false
    ]);
}
```

There are some additional options that you can use:

- countries - array of available countries e.g. \["PL", "DE"\]
- preferred - array or string with preferred country or countries
- country\_attr - attributes for country input
- number\_attr - attributes for number input
- countries\_renderer - a function that returns a string displayed as a country selection option. The following parameters are available: countryName, countryCode, regionCode

### Twig filter

[](#twig-filter)

The displayed phone number in the template can be formatted according to the given pattern. For this purpose, the Twig `phone_number` filter has been implemented.

```
{{ current_customer.phoneNumber|phone_number('E164') }}
{{ current_customer.phoneNumber|phone_number('RFC3966') }}
{{ current_customer.phoneNumber|phone_number('NATIONAL') }}
{{ current_customer.phoneNumber|phone_number('INTERNATIONAL') }}
```

License
-------

[](#license)

MIT

###  Health Score

52

—

FairBetter than 96% of packages

Maintenance70

Regular maintenance activity

Popularity28

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity81

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 95% 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.

###  Release Activity

Cadence

Every ~183 days

Recently: every ~194 days

Total

15

Last Release

167d ago

Major Versions

1.2.0 → 2.0.x-dev2020-02-06

2.0.1 → 3.0.02023-10-16

3.0.x-dev → 4.0.02024-02-02

PHP version history (4 changes)1.0.0PHP ^7.1

2.0.x-devPHP ^7.2

3.0.0PHP &gt;=8.1

4.0.0PHP &gt;=8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/99031579203ae7aff3a32b3309374cb5703c35abc4737509bc6b228b433d9943?d=identicon)[m-adamski](/maintainers/m-adamski)

---

Top Contributors

[![m-adamski](https://avatars.githubusercontent.com/u/21038303?v=4)](https://github.com/m-adamski "m-adamski (19 commits)")[![RoofTurkey](https://avatars.githubusercontent.com/u/8860552?v=4)](https://github.com/RoofTurkey "RoofTurkey (1 commits)")

---

Tags

phonenumber-bundlephpsymfonysymfony-bundle

### Embed Badge

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

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

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k16.7M310](/packages/easycorp-easyadmin-bundle)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[kimai/kimai

Kimai - Time Tracking

4.6k7.4k1](/packages/kimai-kimai)[netgen/layouts-core

Netgen Layouts enables you to build and manage complex web pages in a simpler way and with less coding. This is the core of Netgen Layouts, its heart and soul.

3689.4k10](/packages/netgen-layouts-core)[contao/core-bundle

Contao Open Source CMS

1231.6M2.4k](/packages/contao-core-bundle)

PHPackages © 2026

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