PHP code example of ez-php / sms

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

    

ez-php / sms example snippets


\EzPhp\HttpClient\HttpClientServiceProvider::class,
\EzPhp\Sms\SmsServiceProvider::class,

return [
    'driver' => getenv('SMS_DRIVER') ?: 'null',   // null | array | log | twilio | vonage
    'from' => getenv('SMS_FROM') ?: '',            // default sender number / alphanumeric ID
    'log_path' => getenv('SMS_LOG_PATH') ?: '',    // log driver file ('' = error_log())
    'twilio' => [
        'sid' => getenv('SMS_TWILIO_SID') ?: '',
        'token' => getenv('SMS_TWILIO_TOKEN') ?: '',
    ],
    'vonage' => [
        'key' => getenv('SMS_VONAGE_KEY') ?: '',
        'secret' => getenv('SMS_VONAGE_SECRET') ?: '',
    ],
];

use EzPhp\Sms\Sms;
use EzPhp\Sms\SmsMessage;

Sms::send('+4366412345678', 'Your code is 123456');                   // default sender
Sms::send('+4366412345678', new SmsMessage('Order shipped', 'MyShop')); // sender override

public function __construct(private readonly SmsSenderInterface $sms) {}

$this->sms->send($phone, new SmsMessage('Hello'));

$driver = new \EzPhp\Sms\Driver\ArrayDriver();
Sms::setSender($driver);

// ... code under test ...

$this->assertCount(1, $driver->sentTo('+4366412345678'));
Sms::resetSender();
bash
composer