rm / smsender
Library for sending SMS
Requires
- php: >=7.1
- ext-intl: *
- guzzlehttp/guzzle: >=6.3
- nette/utils: >=2.4
Requires (Dev)
- nette/bootstrap: >=2.4
- nette/caching: >=2.5
- nette/di: >=2.4
- nette/finder: >=2.4
- nette/neon: >=2.4
- nette/tester: >=2.0
- php-parallel-lint/php-parallel-lint: ^1.0
- phpstan/phpstan: >=0.9
Suggests
- nette/di: If you wanna use Nette DI extension
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-08-23 13:54:47 UTC
README
Component for sending SMS through service EuroSMS.sk for Nette.
Supported PHP: 7.1 - 8.5.
Library is possible use too without Nette.
Installation
$ composer require rm/smsender
Minimal example
Pure PHP
$message = new RM\SMSender\Message; $message->setFrom('Example.com') ->setTo('+421900123456') ->setText('SMS text'); try { $smsender = new RM\SMSender\EuroSms\Sender([ 'id' => 'API-id', 'key' => 'API-key', ]); $smsender->send($message); } catch (RM\SMSender\Exception $e) { echo 'ERROR: ' . $e->getMessage(); }
Nette
config.neon
extensions: smsender: RM\SMSender\DI\SMSenderExtension smsender: config: [ id: API-id key: API-key ]
namespace App; use Nette\Application\UI\Presenter; use RM; class SmsPresenter extends Presenter { /** @var RM\SMSender\IMessageFactory @inject */ public $messageFactory; /** @var RM\SMSender\ISender @inject */ public $SMSender; protected function startup() { parent::startup(); $this->SMSender->onBeforeSend[] = function ($message) { $message->setText($message->getText() . ' -- Example.com'); }; $this->SMSender->onSuccess[] = function () { $this->flashMessage('SMS has been sent.', 'success'); }; $this->SMSender->onError[] = function () { $this->flashMessage('Sending SMS failed.', 'warning'); }; } function actionSendSms($to, $text) { $message = $this->messageFactory->create(); $message->setFrom('Example.com') ->setTo($to) ->setText($text); try { $this->SMSender->send($message); } catch (RM\SMSender\Exception $e) {} } }
Full feature configuration
config.neon
extensions: smsender: RM\SMSender\DI\SMSenderExtension smsender: config: [ id: API-id key: API-key ] setDebugMode: TRUE senderClass: RM\SMSender\EuroSms\Sender messageClass: RM\SMSender\EuroSms\Message messageFactoryClass: RM\SMSender\MessageFactory message: setFrom: Example.com signature: ' -- Example.com'
Tests
$ composer update
$ vendor/bin/tester tests -s -C
Some tests call the real EuroSMS gateway (in validate mode, no SMS is sent) and need
credentials in tests/secret.neon — a git-ignored file that must never be committed:
eurosms: id: API-id key: API-key
Without that file those tests skip themselves, the rest of the suite still runs.
In CI the file is generated from the repository secrets EUROSMS_ID and EUROSMS_KEY
(Settings → Secrets and variables → Actions). GitHub does not expose secrets to pull
requests opened from forks, so the gateway tests are skipped there.
Code coverage is collected on the newest supported PHP only, attached to the workflow run as
the coverage artifact, and the build fails if it drops below the threshold in the workflow:
$ vendor/bin/tester tests -s -C --coverage coverage.xml --coverage-src src