2017 © Pedro Peláez
 

symfony-bundle phone-number-bundle

Phone Number Bundle for Symfony

image

m-adamski/phone-number-bundle

Phone Number Bundle for Symfony

  • Thursday, February 1, 2018
  • by m-adamski
  • Repository
  • 0 Watchers
  • 0 Stars
  • 0 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

PhoneNumber Bundle for Symfony 4

This bundle is deprecated! A new repository has been created to maintain the convention of package names. I suggest using this package., (*1)


Custom PhoneNumber Bundle integrating libphonenumber library into Symfony 4 project. This bundle is inspired by PhoneNumberBundle but simplified and created for own projects - of course you can use it if you want., (*2)

Installation

Use Composer to install this bundle into Symfony 4 project:, (*3)

$ composer require m-adamski/symfony-phone-bundle

Configuration

Register new Doctrine Type in config/packages/doctrine.yaml, (*4)

```(yaml) doctrine: dbal: types: phone_number: Adamski\Symfony\PhoneNumberBundle\Doctrine\DBAL\Types\PhoneNumberType, (*5)


This Bundle provide type template for Bootstrap 4. Register it in ``config/packages/twig.yaml`` ```(yaml) twig: form_themes: - '@PhoneNumber/Form/phone_number_widget.html.twig'

You can also overwrite default Symfony Bootstrap 4 template by adding - '@PhoneNumber/Form/bootstrap_4_layout.html.twig' into form_themes parameter:, (*6)

```(yaml) twig: form_themes: - '@PhoneNumber/Form/bootstrap_4_layout.html.twig' - '@PhoneNumber/Form/phone_number_widget.html.twig', (*7)


## How to use it? Bundle provide additional Doctrine Type and Form Type. First, edit entity to use PhoneNumber Type: ```(php) use Adamski\Symfony\PhoneNumberBundle\Model\PhoneNumber; use Adamski\Symfony\PhoneNumberBundle\Validator\Constraints\PhoneNumber as AssertPhoneNumber; /** * @var string * @AssertPhoneNumber * @ORM\Column(name="phone_number", type="phone_number", nullable=true) */ protected $phoneNumber;

Now it's time to provide changes in Form Type:, (*8)

```(php) use Adamski\Symfony\PhoneNumberBundle\Form\PhoneNumberType;, (*9)

public function buildForm(FormBuilderInterface $builder, array $options) { $builder->add("phoneNumber", PhoneNumberType::class, [ "label" => "Phone number", "preferred" => "PL", "required" => false ]); } ```, (*10)

License

MIT, (*11)

The Versions