Skip to content

Validating and formatting phone numbers from country name and phone number using libphonenumber api . It is useful for request type validation for mobile aps and cakephp as backend framework

License

Notifications You must be signed in to change notification settings

sviveks/cakephp-international-phone-validation

Repository files navigation

cakephp-international-phone-validation using country name and libphonenumber

=======================

Validating and formatting phone numbers from country name and phone number using libphonenumber api . It is useful for request type validation for mobile aps and cakephp as backend framework

Installing using composer.

1.check the composer.json is inside your directory or not.
2.Verify the presence of

{
    "require": {
        "giggsey/libphonenumber-for-php": "~7.0"
}

}


3.Download composer from composer
4.install composer.phar into the required directory.

Installation Command

php composer.phar install

REF: Here 5.After installation you will get all required files in vendor/ directory.

After all is done

1.Import LibValidation class into app controller.

App::import('Vendor','LibValidation/verifyNumber');

2.verify your phone number using country name and phone number

$verify=new verifyNumber();
$verify->verifyPhone($country,$phone);

3.Prinit the response to get the status is 1 or 0 and the message..

Example Response

array(
	'valid' => (int) 1,
	'message' => '+91xxxxxxxxxx'
)

Note:if phone number is valid , message contain formatted phone number..

Reference: giggsey libphonenumber-php
/******************* Happy Coding *******************/

About

Validating and formatting phone numbers from country name and phone number using libphonenumber api . It is useful for request type validation for mobile aps and cakephp as backend framework

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages