PHP code example of shetabit / sms

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

    

shetabit / sms example snippets

 bash
$ php artisan vendor:publish --tag=sms-config
 php
return [
    'default' => 'textlocal',

    'drivers' => [
        'kavenegar' => [
            'apiKey' => 'Your Api Key',
            'from' => 'Your Default From Number',
        ],
        // ...
    ],

    'map' => [
        'kavenegar' => \Shetabit\Sms\Drivers\Kavenegar::class,
        // ...
    ],
];
 php
Sms::via('kavenegar')
    ->to(['09xxxxxxxxx'])
    ->message('Hello world')
    ->send();
 php
Sms::via('kavenegar')->config(['from' => '10004346', 'apiKey' => '...']);
 php
namespace App\Sms;

use Shetabit\Sms\Abstracts\Driver;

class MyDriver extends Driver
{
    protected function sendTo(string $recipient) : mixed
    {
        return $this->client->send([
            'apiKey' => $this->setting('apiKey'),
            'from' => $this->setting('from'),
            'to' => $recipient,
            'text' => $this->message->toString(),
        ]);
    }
}