Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/m-adamski/symfony-phone-bundle
[Deprecated] Bundle for Symfony 4 integrating libphonenumber library
https://github.com/m-adamski/symfony-phone-bundle
Last synced: 26 days ago
JSON representation
[Deprecated] Bundle for Symfony 4 integrating libphonenumber library
- Host: GitHub
- URL: https://github.com/m-adamski/symfony-phone-bundle
- Owner: m-adamski
- License: mit
- Created: 2018-01-10T14:39:30.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-11-20T08:03:24.000Z (almost 6 years ago)
- Last Synced: 2023-07-15T09:12:51.937Z (over 1 year ago)
- Language: PHP
- Homepage:
- Size: 50.8 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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](https://github.com/m-adamski/symfony-phone-number-bundle).
---
Custom PhoneNumber Bundle integrating [libphonenumber](https://github.com/giggsey/libphonenumber-for-php) library into Symfony 4 project. This bundle is inspired by [PhoneNumberBundle](https://github.com/misd-service-development/phone-number-bundle) but simplified and created for own projects - of course you can use it if you want.
## Installation
Use Composer to install this bundle into Symfony 4 project:
```
$ composer require m-adamski/symfony-phone-bundle
```## Configuration
Register new Doctrine Type in ``config/packages/doctrine.yaml``
```(yaml)
doctrine:
dbal:
types:
phone_number: Adamski\Symfony\PhoneNumberBundle\Doctrine\DBAL\Types\PhoneNumberType
```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:
```(yaml)
twig:
form_themes:
- '@PhoneNumber/Form/bootstrap_4_layout.html.twig'
- '@PhoneNumber/Form/phone_number_widget.html.twig'
```## 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:
```(php)
use Adamski\Symfony\PhoneNumberBundle\Form\PhoneNumberType;public function buildForm(FormBuilderInterface $builder, array $options) {
$builder->add("phoneNumber", PhoneNumberType::class, [
"label" => "Phone number",
"preferred" => "PL",
"required" => false
]);
}
```## License
MIT