symfony/sms-biuras-notifier
Symfony Notifier bridge for SmsBiuras (smsbiuras.lt). Configure via DSN with UID and API key, set sender (“from”), and optionally enable test_mode (0 real SMS, 1 test). Lets your Symfony app send SMS through SmsBiuras.
symfony/notifier, symfony/messenger) orvlucas/phpdotenv + manual DI).Notification::route('sms', $user)). However, Laravel’s Illuminate\Notifications lacks native Symfony Notifier compatibility, requiring a custom channel or facade.SmsProviderInterface)..env can replace Symfony’s DSN (e.g., SMSBIURAS_UID=xxx), but validation (e.g., required fields) must be manually implemented.$dsn = sprintf('smsbiuras://%s:%s@default?from=%s&test_mode=%d',
config('services.smsbiuras.uid'),
config('services.smsbiuras.api_key'),
config('services.smsbiuras.from'),
config('services.smsbiuras.test_mode')
);
Notifier and TransportFactory in a Laravel service provider.$this->app->singleton(NotifierInterface::class, function ($app) {
return new Notifier([
new SmsBiurasTransport($app->make(BiurasClient::class), $dsn),
]);
});
QueueTransport or by dispatching Laravel events from Symfony’s MessageBus.TransportFactory).test_mode=1 may not align with Laravel’s queue testing (e.g., Queue::fake()).NotificationFailedException must be caught and translated to Laravel’s Exception or logged via Log::error().maxAttempts).SmsBiurasTransport, TwilioTransport interfaces)?.env/config/services.php map to Symfony’s DSN format?sms_sent, sms_failed) needed in Laravel’s monitoring (e.g., Horizon, Datadog)?SmsBiurasClient) that wraps Biuras’ API directly (no Symfony dependency).Notification channel or a custom SmsBiurasChannel.symfony/notifier via Composer, bootstrap in a Laravel service provider.Notifier to Laravel’s Notification facade or events.SmsBiurasClient service in Laravel.test_mode=1.Notification system.SendSms jobs with ShouldQueue.Illuminate\Bus\Queueable).failed_jobs table or a custom table.Log::channel('sms') or Prometheus.7.3.x for PHP 8.1)..env keys:
SMSBIURAS_UID=your_uid
SMSBIURAS_API_KEY=your_key
SMSBIURAS_FROM=YourBrand
SMSBIURAS_TEST_MODE=true
// app/Services/SmsBiurasClient.php
class SmsBiurasClient {
public function send(string $to, string $message): bool {
$client = new \Symfony\Contracts\HttpClient\HttpClient();
$response = $client->request('POST', 'https://api.smsbiuras.lt/send', [
'auth_basic' => [env('SMSBIURAS_UID'), env('SMSBIURAS_API_KEY')],
'json' => [
'to' => $to,
'text' => $message,
'from' => env('SMSBIURAS_FROM'),
],
]);
return $response->getStatusCode() === 200;
}
}
// app/Providers/AppServiceProvider.php
public function register() {
$this->app->singleton(SmsBiurasClient::class, function ($app) {
return new SmsBiurasClient();
});
}
// app/Notifications/Channels/SmsBiurasChannel.php
class SmsBiurasChannel implements Channel {
public function send(Notification $notification, Message $message) {
$client = app(SmsBiurasClient::class);
$client->send($message->to(), $notification->toSms($message));
}
}
// app/Notifications/OrderConfirmed.php
public function via($notifiable) {
return ['sms'];
}
public function toSms($notifiable) {
return "Your order #{$this->order->id} is confirmed!";
}
composer require symfony/notifier:^7.3 with strict version pinning.NotificationFailedException may not surface clearly in Laravel’s error pages.storage/logs/sms.log.How can I help you explore Laravel packages today?