PHP Client for send sms messages via DI.
composer require evildevru/php-sms
- PHP >= 8.0
yii2 configure file
'container' => [
'singletons' => [
SmsInterface::class => static function () {
return new SmsRu($_ENV['SMS_API_KEY'], new SmsClient([
'base_uri' => 'https://sms.ru',
]));
},
],
],
for example controller
/**
* @var SmsInterface
*/
protected SmsInterface $sms;
/**
* @param SmsInterface $sms
*/
public function __construct(SmsInterface $sms)
{
$this->sms = $sms;
}
/**
* @return void
*/
public function actionIndex(?string $phone): void
{
$response = $this->sms->send($phone, 'wake up');
if (!$response->isSuccess()) {
throw new RuntimeException();
}
}
- sms.ru
You can extend this list.
MIT