PHP code example of jorgeanzola / phone-number-verification

1. Go to this page and download the library: Download jorgeanzola/phone-number-verification 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/ */

    

jorgeanzola / phone-number-verification example snippets


...
use JorgeAnzola\PhoneNumberVerification\Traits\MustVerifyPhoneNumber;
use JorgeAnzola\PhoneNumberVerification\Contracts\MustVerifyPhoneNumber as IMustVerifyPhoneNumber;
...

class User implements IMustVerifyPhoneNumber
{
    ...
    use MustVerifyPhoneNumber;
    ...

public function sendVerificationToken(string $phoneNumber): bool;

public function verifyToken(MustVerifyPhoneNumber $user, string $verificationToken): bool;

public function markPhoneNumberAsVerified(MustVerifyPhoneNumber $user): bool;



return [
    'from' => env('APP_NAME'),
    
    'verification_provider' => '\JorgeAnzola\PhoneNumberVerification\Providers\TwilioVerificationProvider',
    
    'twilio_auth_token' => env('TWILIO_AUTH_TOKEN', null),
    
    'twilio_account_sid' => env('TWILIO_ACCOUNT_SID', null),
    
    'twilio_verify_sid' => env('TWILIO_VERIFY_SID', null),
    
    'views' => true,
    
    'verify_phone_number_view' => 'phone_number_verification::verify-phone-number',
    
    'middleware' => ['web', 'auth'],
    
    'verify_token_middleware' => ['throttle:10:1'],
    
    'resend_token_middleware' => ['throttle:5:1'],
    
    'users_table' => 'users',
    
    'phone_number_column' => 'phone_number',
    
    'phone_number_verified_at_column' => 'phone_number_verified_at',
];

sh
php artisan migrate
sh
php artisan vendor:publish --provider="JorgeAnzola\PhoneNumberVerification\Providers\ServiceProvider" --tag=config
sh
php artisan vendor:publish --provider="JorgeAnzola\PhoneNumberVerification\Providers\ServiceProvider" --tag=views
sh
php artisan vendor:publish --provider="JorgeAnzola\PhoneNumberVerification\Providers\ServiceProvider" --tag=migrations
sh
php artisan vendor:publish --provider="JorgeAnzola\PhoneNumberVerification\Providers\ServiceProvider" --tag=lang