PHP code example of artisan / laravel-semaphore

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

    

artisan / laravel-semaphore example snippets


$client = new Client(

  '<SEMAPHORE API KEY>',

  // If the sender is left blank, SEMAPHORE will be the default sender name.
  '<SENDER>',

);

$client->message()->send('0917xxxxxxx', '<Your message here>');

use Humans\Semaphore\Laravel\Facades\Semaphore;

Semaphore::message()->send(
    '0917xxxxxxx',
    '<Your message here>'
);


class User {
    use Notifiable;

    // ...

    public function routeNotificationForSemaphore()
    {
        return $this->mobile_number;
    }
}

use Humans\Semaphore\Laravel\Contracts\UsesSemaphore;

class Welcome extends Notification implements UsesSemaphore
{
    public function via($notifiable): array
    {
        return [SemaphoreChannel::class];
    }

    public function toSemaphore($notifiable): SemaphoreMessage
    {
        return (new SemaphoreMessage)
            ->message('<Your message here>');
    }
}

User::first()->notify(new Welcome);

use Humans\Semaphore\Laravel\SemaphoreChannel;use Illuminate\Support\Facades\Notification;

Notification::route(SemaphoreChannel::class, '0917xxxxxxx')->notify(new Welcome);