aybimyazilim/dataport-sms-notification
Composer 安装命令:
composer require aybimyazilim/dataport-sms-notification
包简介
DataPort SMS notification channel for Laravel
README 文档
README
Bu paket, Laravel uygulamalarında DataPort SMS servisi üzerinden SMS gönderimi için notification channel sağlar.
✨ Özellikler
- ✅ Kapsamlı hata yakalama ve handling
- ✅ Detaylı SMS gönderim logları
- ✅ Veritabanı tabanlı SMS takibi
- ✅ İstatistik ve raporlama
- ✅ Otomatik retry mekanizması
- ✅ Rate limiting desteği
- ✅ Telefon numarası validasyonu
- ✅ Queue desteği
- ✅ Artisan komutları
- ✅ Comprehensive testing
🚀 Kurulum
Composer ile paketi yükleyin:
composer require AybimYazilim/dataport-sms-notification
Konfigürasyon dosyasını yayınlayın:
php artisan vendor:publish --tag=dataport-sms-config
Migration'ları Yayınlayın ve Çalıştırın
php artisan vendor:publish --tag=dataport-sms-migrations php artisan migrate
⚙️ Konfigürasyon
.env dosyanıza DataPort SMS bilgilerinizi ekleyin:
DATAPORT_SMS_USERNAME=your_username DATAPORT_SMS_PASSWORD=your_password DATAPORT_SMS_SCOPE=your_scope DATAPORT_SMS_ORIGINATOR="YOUR COMPANY" DATAPORT_SMS_SHORT_NUMBER=5967 DATAPORT_SMS_TIMEOUT=120 DATAPORT_SMS_MAX_MESSAGE_LENGTH=1000
Kullanım
Basit Notification
<?php namespace App\Notifications; use AybimYazilim\DataPortSms\Notifications\DataPortSmsNotification; class OrderConfirmation extends DataPortSmsNotification { private $order; public function __construct($order) { $this->order = $order; } public function toDataPortSms($notifiable): array { return [ 'text' => "Siparişiniz #{$this->order->id} onaylandı!", 'phone' => $notifiable->phone, // Opsiyonel ]; } }
<?php namespace App\Notifications; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Notifications\Notification; class OrderConfirmation extends Notification implements ShouldQueue { use Queueable; private $order; public function __construct($order) { $this->order = $order; } public function via($notifiable) { return ['dataport-sms']; } public function toDataPortSms($notifiable): array { return [ 'text' => "Siparişiniz #{$this->order->id} onaylandı! Toplam: {$this->order->total}₺", 'phone' => $notifiable->phone, // Opsiyonel ]; } }
Notification Gönderme
// User model üzerinden $user = User::find(1); $user->notify(new OrderConfirmation($order)); // Notification facade ile use Illuminate\Support\Facades\Notification; Notification::send($users, new OrderConfirmation($order)); // Belirli bir telefon numarasına Notification::route('dataport-sms', '905551234567') ->notify(new OrderConfirmation($order));
Model Konfigürasyonu
User modelinizde telefon numarası için routing tanımlayabilirsiniz:
class User extends Authenticatable { // Telefon numarası için özel routing public function routeNotificationForDataPortSms() { return $this->phone_number; } // Veya telefon alanı için accessor public function getPhoneAttribute() { return $this->mobile ?? $this->telephone; } // SMS loglarına erişim public function smsLogs() { return $this->morphMany(SmsLog::class, 'notifiable'); } }
Message Builder Kullanımı
use AybimYazilim\DataPortSms\Messages\DataPortSmsMessage; public function toDataPortSms($notifiable): array { return (new DataPortSmsMessage('Mesaj içeriği')) ->to('905551234567') ->toArray(); }
Queue Kullanımı
Notification sınıfınız otomatik olarak queue edilir:
// Queue konfigürasyonu public function __construct($order) { $this->order = $order; $this->onQueue('sms'); // Özel queue $this->delay(now()->addMinutes(5)); // Gecikme }
Test Etme
Artisan komutu ile SMS test edebilirsiniz:
php artisan dataport:test-sms 905551234567 "Test mesajı"
Unit Tests
use AybimYazilim\DataPortSms\Tests\TestCase; use Illuminate\Support\Facades\Http; class MyNotificationTest extends TestCase { /** @test */ public function it_sends_sms_notification() { Http::fake([ 'api.dataport.com.tr/*' => Http::response(['success' => true]) ]); $user = new User(['phone' => '905551234567']); $user->notify(new MyNotification()); Http::assertSent(function ($request) { return str_contains($request->url(), 'dataport.com.tr'); }); } }
Hata Yakalama
use AybimYazilim\DataPortSms\Exceptions\DataPortSmsException; use AybimYazilim\DataPortSms\Exceptions\InvalidPhoneNumberException; use AybimYazilim\DataPortSms\Exceptions\QuotaExceededException; try { $user->notify(new OrderConfirmation($order)); } catch (InvalidPhoneNumberException $e) { Log::error('Geçersiz telefon numarası: ' . $e->getMessage()); } catch (QuotaExceededException $e) { Log::error('SMS kotası dolmuş: ' . $e->getMessage()); } catch (DataPortSmsException $e) { Log::error('SMS gönderilemedi: ' . $e->getMessage()); }
🗃️ SMS Logları
SMS gönderim logları sms_logs tablosunda otomatik olarak kaydedilir:
use AybimYazilim\DataPortSms\Models\SmsLog; // Başarılı SMS'ler $successfulSms = SmsLog::successful()->get(); // Başarısız SMS'ler $failedSms = SmsLog::failed()->get(); // Bekleyen SMS'ler $pendingSms = SmsLog::pending()->get(); // Belirli bir kullanıcının SMS'leri $userSms = SmsLog::where('notifiable_type', User::class) ->where('notifiable_id', $userId) ->get();
Konfigürasyon Seçenekleri
config/dataport-sms.php dosyasındaki seçenekler:
| Seçenek | Varsayılan | Açıklama |
|---|---|---|
username |
- | DataPort kullanıcı adı |
password |
- | DataPort şifre |
scope |
- | DataPort scope |
originator |
'LARAVEL' | SMS gönderen adı |
short_number |
'5967' | Kısa numara |
timeout |
120 | İstek timeout süresi |
log_requests |
true | İstekleri logla |
log_responses |
true | Cevapları logla |
Lisans
Bu paket MIT lisansı altında yayınlanmıştır.
Changelog
v2.0.0
- ✅ Kapsamlı hata yakalama sistemi
- ✅ Detaylı SMS loglama
- ✅ İstatistik ve raporlama
- ✅ Artisan komutları
- ✅ Rate limiting
- ✅ Retry mekanizması
- ✅ Gelişmiş validasyon
v1.0.0
- İlk sürüm
- DataPort SMS entegrasyonu
- Laravel notification channel desteği
- Queue desteği
- Test komutları
aybimyazilim/dataport-sms-notification 适用场景与选型建议
aybimyazilim/dataport-sms-notification 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 63 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 09 月 10 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「sms」 「notification」 「laravel」 「turkey」 「dataport」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 aybimyazilim/dataport-sms-notification 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 aybimyazilim/dataport-sms-notification 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 aybimyazilim/dataport-sms-notification 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
This package makes it easy to send notifications via AfricasTalking with Laravel
Apple Push Notification & Feedback Provider
Throttle notifications on a per-channel basis
SDK for payment gateway PlatbaMobilom.sk for PHP7.0
Extensible library for building notifications and sending them via different delivery channels.
Simple javascript toast notifications
统计信息
- 总下载量: 63
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 14
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-09-10