Download the PHP package mahdi-hejazi/laravel-ghasedak-sms without Composer
On this page you can find all versions of the php package mahdi-hejazi/laravel-ghasedak-sms. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mahdi-hejazi/laravel-ghasedak-sms
More information about mahdi-hejazi/laravel-ghasedak-sms
Files in mahdi-hejazi/laravel-ghasedak-sms
Package laravel-ghasedak-sms
Short Description Modern Laravel package for Ghasedak SMS API with template and simple SMS support
License MIT
Informations about the package laravel-ghasedak-sms
Laravel Ghasedak SMS
Modern Laravel package for Ghasedak SMS API with template and simple SMS support.
packagist url: https://packagist.org/packages/mahdi-hejazi/laravel-ghasedak-sms
Features
- ✅ Template-based SMS (OTP, verification codes, etc.)
- ✅ Simple SMS (free text messages)
- ✅ Queue support with Laravel notifications
- ✅ Persian error messages
- ✅ Configurable templates
- ✅ Logging support
Installation
Requirements
- PHP 8.1, 8.2, or 8.3
- Laravel 9, 10, 11, or 12
- Composer
Install via Composer
Publish Configuration
Configuration
Add your Ghasedak credentials to your .env file:
Usage
OTP SMS Usage Examples
New OTP API Features
The new OTP API endpoint supports:
- ✅ Named parameters (instead of positional param1, param2, etc.)
- ✅ Multiple recipients in single request
- ✅ Client reference IDs for tracking
- ✅ Scheduled sending
- ✅ Voice messages
- ✅ Better response format with cost information
Basic Usage
0. Add template to Laravel Config
1. Single OTP with Named Parameters
2. Using Notification Classes
3. Advanced Features
Scheduled OTP
Voice OTP
Custom Client Reference ID
Template Configuration (old version of OTP)
1. Create Templates in Ghasedak Panel
Create templates at ghasedak.me with named parameters:
Example Templates:
2. Add to Laravel Config
Response Format
The new OTP API returns detailed response:
Error Handling
Migration from Old API
Before (Old Template API):
After (New OTP API):
Best Practices
- Use meaningful client reference IDs for tracking
- Test templates in Ghasedak panel before using in code
- Handle errors gracefully with try-catch blocks
- Monitor costs using the totalCost field in responses
- Use bulk methods for multiple recipients to reduce API calls
- Clean parameter values - avoid special characters
- Use scheduled sending for time-sensitive messages
Available Factory Methods
Adding Custom Factory Methods
You can extend the notification classes to add your own factory methods:
Method 1: Extend the Notification Class
Usage:
Method 2: Create Your Own Notification Service
Usage:
Method 3: Using Macros (Advanced)
Add to your AppServiceProvider.php:
Usage:
Template Requirements
When adding custom templates, remember:
- Create in Ghasedak Panel: First create your template at ghasedak.me
- Add to Config: Add template mapping to
config/ghasedak.php - Parameter Limit: Maximum 10
- parameters (
%param1%,%param2%, ...%param10%)
Example Custom Template Setup:
-
In Ghasedak Panel:
-
In config/ghasedak.php:
- In Your Code:
Queue Support
Both notifications support Laravel queues:
Error Handling
Configuration
Prerequisites
⚠️ Important: Before using template-based SMS, you must:
- Create templates in Ghasedak panel at ghasedak.me
- Go to
SMS Panel > Templates > Create Template - Create your template with parameters like
%param1%,%param2%,%param3%, ...%param10% - Get the template name from your panel
- Add template name to your config
Templates
Define your SMS templates in config/ghasedak.php:
Example Ghasedak Template:
Step-by-Step Template Setup
1. Create Template in Ghasedak Panel
- Visit ghasedak.me and login
- Go to SMS Panel > Templates
- Click Create New Template
- Fill template details:
- Template Name:
verifyCodeTemplate - Template Text:
کد تایید شما: %param1% - این کد 5 دقیقه معتبر است - Category: Select appropriate category
- Template Name:
- Submit and wait for approval
2. Add to Laravel Config
3. Use in Code
Advanced Examples
Advanced Examples
E-commerce Notifications
Medical Center Notifications
Bulk SMS Service
Logging
Control SMS logging:
Testing
Mock Tests (Free - No API Key Required)
Real API Tests (Costs Money - Sends Real SMS)
-
Set your real API credentials
Edit tests/.env with your GHASEDAK_API_KEY and template name
- Run real API tests
Note: Mock tests use fake responses and don't send real SMS. Integration tests send actual SMS and will cost money.
API Updates
This package uses the latest Ghasedak REST API (v1) with:
- ✅ New endpoints (
gateway.ghasedak.me) - ✅ JSON requests instead of form data
- ✅ Enhanced error responses
- ✅ Up to 10 template parameters
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.