PHP code example of devsarfo / laraphone

1. Go to this page and download the library: Download devsarfo/laraphone 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/ */

    

devsarfo / laraphone example snippets


'phone' => 'phone:NO,GH',
// 'phone' => new PhoneNumberRule(['NO', 'GH'])

'country_code' => 'red', new PhoneNumberRule($this->country_code)],

'phone' => 'The :attribute field must be a valid phone number.',

use DevSarfo\LaraPhone\Models\PhoneNumber;

(string) new PhoneNumber('+4722334455');    // +4722334455
(string) new PhoneNumber('22334455', 'NO'); // +4722334455

phone('+233244123456');             // PhoneNumber instance
phone('0244123456', 'GH');          // PhoneNumber instance
phone('0244123456', 'GH', $format); // string

$phone = new PhoneNumber('0244123456', 'GH');

$phone->format($format);       // See libphonenumber\PhoneNumberFormat
$phone->formatE164();          // +233244123456
$phone->formatInternational(); // +233 24 412 3456
$phone->formatRFC3966();       // tel:+233-24-412-3456
$phone->formatNational();      // 024 412 3456
bash
php artisan vendor:publish --tag="laraphone-config"
bash
php artisan vendor:publish --tag="laraphone-translations"