Adds libphonenumber to Silverstripe

Installs: 459

Dependents: 0

Suggesters: 0

Security: 0

Stars: 2

Watchers: 2

Forks: 2

Open Issues: 1


dev-master 2016-03-25 08:00 UTC

This package is auto-updated.

Last update: 2020-08-29 05:08:00 UTC


Provide some helper services to deal with phone numbers in Silverstripe

This module integrates libphonenumber as the utility to parse and validate phonenumbers. The fork used is : https://github.com/giggsey/libphonenumber-for-php

Most of the time, it's a good idea to set the country of the phone number. Otherwise, current locale will be used. If the country is dynamic, you can set a country field thanks to the setCountryField method.

The value is dynamically formatted through ajax to avoid loading huge js libraries. You can also easily validate values (for example, with a ZenValidator remote constraint which targets /libphonenumber/validate url) if needed.

Sample code:

$phone = new LibPhoneNumberField('phone', 'Phone number');

$validator = ZenValidator::create();
$validator->setConstraint('phone', Constraint_remote::create('/libphonenumber/validate',null,array('data' => array('country' => 'BE'))));

This module also provide an extension to apply to dataobject, for example to members

    - LibPhoneNumberExtension

This will add to fields, one "CountryCode" and one "PhoneNumber" to the data object.

Twilio lookup

You can also make lookups with Twilio provided that you have defined the following constants:


Twilio lookups are accessible through the controller (/libphonenumber/lookup) or through a static method PhoneNumberExtension::twilioLookup()


Tested with Silverstripe 3.1


LeKoala - thomas@lekoala.be