libphonenumber One simple libphonenumber php class for Yii framework

  1. Requirements
  2. Installation
  3. Usage
  4. Resources

This is just a wrapper class of libphonenumber by Davide Mendolia's extension libphonenumber-for-PHP

Requirements

...requirements of using this extension (e.g. Yii 1.1 or above)...

Installation

  • Download and extract extension files to the directory protected/vendors

Usage

Wherever you want to validate the phone number,use the following codes

Yii::setPathOfAlias('libphonenumber',Yii::getPathOfAlias('application.vendors.libphonenumber'));

$phonenumber=new libphonenumber\LibPhone($your_phone_number);

/**
  * Checking the number is valid or not  
  *
  * @return boolean
  */
$phonenumber->validate();   //return true if valid

//to convert to international format
$phonenumber->toInternational();

//to get national format
$phonenumber->toNational();

//to get E164 format
$phonenumber->toE164();

/*to get out of country calling number format
 *need to pass the region value
 */
$phonenumber->toOutOfCountryCallingNumber($region);

Resources

5 1
10 followers
881 downloads
Yii Version: 1.1
License: BSD-2-Clause
Category: Validation
Developed by: Riyas
Created on: Apr 14, 2013
Last updated: 10 years ago

Downloads

show all

Related Extensions