PHP code example of padosoft / laravel-rebel-channels

1. Go to this page and download the library: Download padosoft/laravel-rebel-channels 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/ */

    

padosoft / laravel-rebel-channels example snippets


use Padosoft\Rebel\Channels\Enums\Channel;
use Padosoft\Rebel\Channels\Routing\VerificationRouter;
use Padosoft\Rebel\Core\Context\SecurityContext;
use Padosoft\Rebel\Core\Identifiers\PhoneIdentifier;

$router = app(VerificationRouter::class);
$start  = $router->start(PhoneIdentifier::from('+39 333 1234567'), Channel::Sms, SecurityContext::fromRequest($request));

$start = $router->start($phone, Channel::Sms, $ctx);
// store $start->reference (already signed) for the check step

$result = $router->check($phone, $request->string('code'), $reference, $ctx);
if ($result->approved()) {
    // the number is verified
}

// config/rebel-channels.php
'providers' => ['twilio', 'vonage'],

'fraud' => [
    'allowed_prefixes' => ['+39', '+1', '+44'], // only Italy, US, UK
    'per_prefix' => ['length' => 3, 'max_per_window' => 50, 'window_seconds' => 3600],
],

$router->start($phone, Channel::Sms, $ctx, $request->string('captcha_token'));

use Padosoft\Rebel\Core\Models\RebelAuthEvent;

RebelAuthEvent::query()->where('event_type', 'channel.verification.blocked')->get(); // see WHY sends were stopped

// config/iam-agents.php — point IAM at the notifier:
'elevation' => ['notifier' => \Padosoft\Rebel\Channels\Delegation\ChannelElevationNotifier::class],

// AppServiceProvider — only YOUR app knows the user's verified number:
$this->app->bind(
    \Padosoft\Rebel\Channels\Delegation\ElevationRecipientResolver::class,
    MyUserPhoneResolver::class,
);

// config/rebel-channels.php — fallback order (first accepted delivery wins):
'elevation' => ['channels' => ['whatsapp', 'sms']],