PHP code example of shankar / country-phone-validator

1. Go to this page and download the library: Download shankar/country-phone-validator library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

shankar / country-phone-validator example snippets


'providers' => [
    // ...
    Shankar\CountryPhoneValidator\CountryPhoneValidatorServiceProvider::class,
],

use Shankar\CountryPhoneValidator\Rules\PhoneNumber;

$request->validate([
    'phone' => ['

use Shankar\CountryPhoneValidator\Rules\ValidPhoneByCountryName;

$request->validate([
    'phone' => ['

use Shankar\CountryPhoneValidator\Rules\ValidPhoneByDialCode;

$request->validate([
    'phone' => ['

use Shankar\CountryPhoneValidator\Countries;

$countries = Countries::all();
// Example output:
// [
//     [
//         'name' => 'India',
//         'dial_code' => '+91',
//         'regex' => '/^...$/'
//     ],
//     ...
// ]