{"id":37014551,"url":"https://github.com/itxshakil/laravel-fast2sms","last_synced_at":"2026-01-17T03:01:40.985Z","repository":{"id":309413789,"uuid":"1036191349","full_name":"itxshakil/laravel-fast2sms","owner":"itxshakil","description":"A robust and simple-to-use Laravel package for sending SMS messages via the Fast2sms API. This package offers a powerful, fluent interface that simplifies sending different types of SMS, including Quick, DLT, and OTP messages.","archived":false,"fork":false,"pushed_at":"2025-12-18T17:46:49.000Z","size":96,"stargazers_count":16,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-14T01:38:11.666Z","etag":null,"topics":["fast2sms","fast2sms-api","sms"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/itxshakil.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":["itxshakil"],"custom":"https://paypal.me/itxshakil"}},"created_at":"2025-08-11T17:35:30.000Z","updated_at":"2025-12-31T14:28:58.000Z","dependencies_parsed_at":"2025-08-11T20:17:42.366Z","dependency_job_id":"91e786c9-078f-42e5-a13b-00f7d722f31d","html_url":"https://github.com/itxshakil/laravel-fast2sms","commit_stats":null,"previous_names":["itxshakil/laravel-fast2sms"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/itxshakil/laravel-fast2sms","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itxshakil%2Flaravel-fast2sms","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itxshakil%2Flaravel-fast2sms/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itxshakil%2Flaravel-fast2sms/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itxshakil%2Flaravel-fast2sms/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/itxshakil","download_url":"https://codeload.github.com/itxshakil/laravel-fast2sms/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itxshakil%2Flaravel-fast2sms/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28492593,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T02:39:23.645Z","status":"ssl_error","status_checked_at":"2026-01-17T02:34:19.649Z","response_time":85,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["fast2sms","fast2sms-api","sms"],"created_at":"2026-01-14T01:27:06.292Z","updated_at":"2026-01-17T03:01:40.955Z","avatar_url":"https://github.com/itxshakil.png","language":"PHP","funding_links":["https://github.com/sponsors/itxshakil","https://paypal.me/itxshakil"],"categories":[],"sub_categories":[],"readme":"# Laravel Fast2sms 📲\n\n[![Latest Version](https://img.shields.io/packagist/v/itxshakil/laravel-fast2sms.svg?style=flat-square)](https://packagist.org/packages/itxshakil/laravel-fast2sms)\n[![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)\n\nA **Laravel package** for sending SMS using the [Fast2sms API](https://www.fast2sms.com/) with a **fluent, expressive interface**.  \nSupports **Quick SMS**, **DLT templates**, **OTP**, queueing, scheduling, and balance checks.\n\n---\n\n## Table of Contents\n\n- [Requirements](#requirements)\n- [Features](#features)\n- [Quick Start Guide](#quick-start-guide)\n- [Installation](#installation)\n- [Configuration](#configuration)\n- [Basic Usage](#basic-usage)\n- [API Methods](#api-methods)\n- [Error Handling](#exceptions)\n- [Advanced Features](#advanced-features)\n- [Documentation](#documentation)\n- [Contributing](#contributing)\n- [License](#license)\n\n---\n\n## Requirements\n\n- **PHP 8.3 or higher**\n- **Laravel 12 or higher** (the package relies on `illuminate/support` v12+)\n\n---\n\n## ✨ Features\n\n- **Fluent Interface:** Chainable API for building and sending SMS.\n- **Multiple Routes:** Supports **Quick SMS**, **DLT SMS**, and **OTP SMS**.\n- **Queue Support:** Built-in job queueing for asynchronous processing.\n- **Easy Configuration:** Simple config file and environment variable setup.\n- **DLT Compliant:** Send DLT messages with templates and variables.\n- **Service \u0026 Facade:** Use the `Fast2sms` service directly or via facade.\n- **API Helpers:** Check wallet balance and DLT details.\n- **Artisan Commands:** Publish configuration and monitor balance.\n\n---\n\n## 🚀 Quick Start Guide\n\n1. **Install via Composer:**\n    ```bash\n    composer require itxshakil/laravel-fast2sms\n    ```\n\n2. **Publish Configuration:**\n    ```bash\n    php artisan vendor:publish --tag=fast2sms-config\n    ```\n   This creates `fast2sms.php` in your `config` directory.\n\n3. **Update Environment Variables:**\n   Add to your `.env`:\n    ```ini\n    FAST2SMS_API_KEY=\"YOUR_API_KEY\"\n    FAST2SMS_DEFAULT_SENDER_ID=\"FSTSMS\"\n    FAST2SMS_DEFAULT_ROUTE=\"dlt\"\n    ```\n\n4. **Send Your First DLT SMS:**\n    ```php\n    use Shakil\\Fast2sms\\Facades\\Fast2sms;\n\n    Fast2sms::dlt(\n        numbers: '9999999999',\n        templateId: 'YOUR_TEMPLATE_ID',\n        variablesValues: ['John Doe'],\n        senderId: 'YOUR_SENDER_ID'\n    );\n    ```\n\n---\n\n## ⚙️ Installation\n\nInstall the package via Composer:\n\n```bash\ncomposer require itxshakil/laravel-fast2sms\n```\nSupports **Laravel auto-discovery**. No manual provider registration required.\n\n---\n\n## 🛠️ Configuration\n\n**Publish the configuration file:**\n```bash\nphp artisan vendor:publish --tag=fast2sms-config\n```\nCreates `fast2sms.php` in your `config` directory.\n\n**Environment Variables:**\nUpdate your `.env` file:\n```ini\nFAST2SMS_API_KEY=\"YOUR_API_KEY\"\nFAST2SMS_DEFAULT_SENDER_ID=\"FSTSMS\"\nFAST2SMS_DEFAULT_ROUTE=\"dlt\"\n```\n\n---\n\n## 📝 Basic Usage\n\nUse the **`Fast2sms` facade** for convenience. Three primary sending methods, each with a dedicated helper.\n\n### Quick SMS\n\n```php\nuse Shakil\\Fast2sms\\Facades\\Fast2sms;\nuse Shakil\\Fast2sms\\Enums\\SmsLanguage;\n\nFast2sms::quick('9999999999', 'Hello, this is a Quick SMS!');\nFast2sms::quick('9999999999', 'नमस्ते! यह एक क्विक एसएमएस है।', SmsLanguage::UNICODE);\n```\n\n### DLT SMS\n\n```php\nuse Shakil\\Fast2sms\\Facades\\Fast2sms;\n\nFast2sms::dlt(\n    numbers: '9999999999',\n    templateId: 'YOUR_TEMPLATE_ID',\n    variablesValues: ['John Doe'],\n    senderId: 'YOUR_SENDER_ID'\n);\n```\n\n### OTP SMS\n\n```php\nuse Shakil\\Fast2sms\\Facades\\Fast2sms;\n\nFast2sms::otp('9999999999', '123456');\n```\n\n### Fluent Interface\n\n```php\nuse Shakil\\Fast2sms\\Facades\\Fast2sms;\nuse Shakil\\Fast2sms\\Enums\\SmsRoute;\n\nFast2sms::to('9999999999')\n    -\u003eroute(SmsRoute::DLT)\n    -\u003esenderId('YOUR_SENDER_ID')\n    -\u003etemplateId('YOUR_TEMPLATE_ID')\n    -\u003evariables(['John Doe'])\n    -\u003esend();\n```\n\n### Check Wallet Balance\n\n```php\nuse Shakil\\Fast2sms\\Facades\\Fast2sms;\n\n$response = Fast2sms::checkBalance();\n\nif ($response-\u003esuccess()) {\n    echo \"Wallet Balance: {$response-\u003ebalance}\\n\";\n    echo \"SMS Count: {$response-\u003esmsCount}\\n\";\n}\n```\n\n### Check DLT Manager Details\n\n```php\nuse Shakil\\Fast2sms\\Facades\\Fast2sms;\nuse Shakil\\Fast2sms\\Enums\\DltManagerType;\nuse Shakil\\Fast2sms\\Responses\\DltManagerResponse;\n\n// Get DLT sender IDs\n/** @var DltManagerResponse $sendersResponse */\n$sendersResponse = Fast2sms::dltManager(DltManagerType::SENDER);\n\nforeach ($sendersResponse-\u003egetSenders() as $sender) {\n    echo \"Sender ID: {$sender['sender_id']} | Entity ID: {$sender['entity_id']}\\n\";\n}\n```\n\n---\n\n## 📚 API Methods\n\n| Method | Description |\n|---|---|\n| `-\u003eto(string|array $numbers)` | Sets recipient mobile number(s). |\n| `-\u003emessage(string $message)` | Sets message content (DLT: template ID). |\n| `-\u003esenderId(string $senderId)` | Sets DLT-approved sender ID. |\n| `-\u003eroute(SmsRoute $route)` | Sets SMS route (`DLT`, `QUICK`, `OTP`, etc.). |\n| `-\u003eentityId(string $entityId)` | Sets DLT Principal Entity ID. |\n| `-\u003etemplateId(string $templateId)` | Sets DLT Content Template ID. |\n| `-\u003evariables(array|string $values)` | Sets pipe-separated variable values for DLT template. |\n| `-\u003eflash(bool $flash)` | Toggles flash message. |\n| `-\u003elanguage(SmsLanguage $language)` | Sets message language (`ENGLISH`, `UNICODE`). |\n| `-\u003eschedule(string|DateTimeInterface $time)` | Schedules SMS at a specific time. |\n| `-\u003esend()` | Sends SMS with configured parameters. |\n| `-\u003equick(...)` | Quick helper to send simple SMS. |\n| `-\u003edlt(...)` | Helper for DLT messages. |\n| `-\u003eotp(...)` | Helper for OTP messages. |\n| `-\u003echeckBalance()` | Retrieves wallet balance. |\n| `-\u003edltManager(string $type)` | Retrieves DLT manager details for `sender` or `template`. |\n\n---\n\n## ⚠️ Exceptions\n\nAll errors throw `Fast2smsException`.  \nCatch them when handling SMS sending:\n\n```php\nuse Shakil\\Fast2sms\\Exceptions\\Fast2smsException;\n\ntry {\n    Fast2sms::quick('9999999999', 'Hello World');\n} catch (Fast2smsException $e) {\n    logger()-\u003eerror(\"SMS failed: \" . $e-\u003egetMessage());\n}\n```\n\n---\n\n## 🧩 Advanced Features\n\n### 🚀 Queue Integration\n\nSupports Laravel's queue system for asynchronous SMS sending.\n\n**Queue Configuration:**\n```php\n// config/queue.php \n'connections' =\u003e [ \n    'redis' =\u003e [ \n        'driver' =\u003e 'redis', \n        // ... other redis configuration \n    ], \n],\n```\n\n**Queueing SMS Messages:**\n```php\nuse Shakil\\Fast2sms\\Facades\\Fast2sms;\n\n// Queue a Quick SMS\nFast2sms::quickQueue('9999999999', 'Hello from queue!');\n\n// Queue a DLT SMS\nFast2sms::dltQueue(\n    numbers: '9999999999',\n    templateId: 'YOUR_TEMPLATE_ID',\n    variablesValues: ['John Doe'],\n    senderId: 'YOUR_SENDER_ID'\n);\n\n// Queue an OTP SMS\nFast2sms::otpQueue('9999999999', '123456');\n```\n\n**Advanced Queue Options:**\n```php\nuse Shakil\\Fast2sms\\Facades\\Fast2sms;\nuse Shakil\\Fast2sms\\Enums\\SmsRoute;\n\nFast2sms::to('9999999999')\n    -\u003emessage('Test message')\n    -\u003eroute(SmsRoute::QUICK)\n    -\u003eonConnection('redis')   // Specify queue connection\n    -\u003eonQueue('sms')          // Specify queue name\n    -\u003edelay(now()-\u003eaddMinutes(10)) // Add delay\n    -\u003equeue();                // Queue the SMS\n```\n\n**Queue Methods:**\n\n| Method | Description |\n|---|---|\n| `-\u003equeue()` | Queue SMS using default settings |\n| `-\u003eonConnection(string $name)` | Set queue connection |\n| `-\u003eonQueue(string $queue)` | Set queue name |\n| `-\u003edelay($delay)` | Set delay before processing |\n| `-\u003equickQueue()` | Queue Quick SMS |\n| `-\u003edltQueue()` | Queue DLT SMS |\n| `-\u003eotpQueue()` | Queue OTP SMS |\n\n---\n\n### 📱 Notifications Channel\n\nUse Fast2sms as a notification channel in your Laravel applications:\n\n**Create a Notification:**\n```php\nuse Illuminate\\Notifications\\Notification;\nuse Shakil\\Fast2sms\\Facades\\Fast2sms;\nuse Shakil\\Fast2sms\\Enums\\SmsRoute;\nclass LowSmsBalanceNotification extends Notification\n{\n    public function __construct(\n        protected float $balance,\n        protected float $threshold\n    ) {}\n\n    public function via($notifiable)\n    {\n        return ['fast2sms'];\n    }\n\n    public function toFast2sms($notifiable)\n    {\n        return Fast2sms::to($notifiable-\u003ephone)\n            -\u003emessage(\"Low SMS balance: {$this-\u003ebalance}. Threshold: {$this-\u003ethreshold}.\")\n            -\u003eroute(SmsRoute::QUICK)\n            -\u003esend();\n    }\n}\n```\n**Use route in SMS Notification:**\n```php\nuse Illuminate\\Notifications\\RoutesNotifications;\nuse Illuminate\\Notifications\\Notifiable;\nuse Illuminate\\Database\\Eloquent\\Model;\nclass User extends Model\n{\n    use Notifiable, RoutesNotifications;\n\n    protected $fillable = ['name', 'email', 'phone'];\n\n    public function routeNotificationForFast2sms()\n    {\n        return $this-\u003ephone; // Return the phone number for Fast2sms\n    }\n}\n```\n\n**Send the notification:**\n```php\nuse App\\Notifications\\LowSmsBalanceNotification;\nuse Illuminate\\Support\\Facades\\Notification;\nNotification::route('fast2sms', '9999999999')\n    -\u003enotify(new LowSmsBalanceNotification(500, 1000));\n```\n\n**Model Setup:**\nEnsure your model has a `phone` attribute:\n```php\nuse Illuminate\\Database\\Eloquent\\Model;\nclass User extends Model\n{\n    protected $fillable = ['name', 'email', 'phone'];\n}\n```\n---\n\n**Schedule the command:**\n```bash\nphp artisan sms:monitor --threshold=500\n```\n\nIf no threshold is specified, the value from your configuration file will be used:\n\n```php\n// config/fast2sms.php\n'balance_threshold' =\u003e 1000,\n```\n\n**Listen for the event in `AppServiceProvider`:**\n```php\nuse App\\Notifications\\LowSmsBalanceNotification;\nuse Illuminate\\Support\\Facades/Event;\nuse Illuminate\\Support\\Facades\\Notification;\nuse Shakil\\Fast2sms\\Events\\LowBalanceDetected;\n\npublic function boot(): void\n{\n    Event::listen(function (LowBalanceDetected $event) {\n        Notification::route('mail', 'dev@example.com')\n            -\u003enotify(new LowSmsBalanceNotification(\n                $event-\u003ebalance,\n                $event-\u003ethreshold\n            ));\n    });\n}\n```\n\n**Example schedule in `App\\Console\\Kernel`:**\n```php\nprotected function schedule(Schedule $schedule)\n{\n    $schedule-\u003ecommand('sms:monitor')-\u003ehourly();\n}\n```\n\n---\n\n\n## 📚 Documentation\n\nLearn how to use Laravel Fast2sms effectively:\n\n### Getting Started\n- [Installation and Requirements](docs/installation.md)\n- [Configuration](docs/configuration.md)\n- [Basic Usage](docs/basic-usage.md)\n\n### Features\n- [API Reference](docs/api-reference.md)\n- [Advanced Usage](docs/advanced-usage.md)\n- [Queue Integration](docs/queues.md)\n- [Notifications](docs/notifications.md)\n- [Events \u0026 Listeners](docs/events.md)\n\n---\n\n## 🤝 Contributing\n\nContributions are always welcome!  \nOpen an issue or submit a pull request for bugs or suggestions.\n\n---\n\n## 📄 License\n\nThis package is open-source software licensed under the **[MIT license](https://opensource.org/licenses/MIT)**.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fitxshakil%2Flaravel-fast2sms","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fitxshakil%2Flaravel-fast2sms","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fitxshakil%2Flaravel-fast2sms/lists"}