Download the PHP package amyavari/iran-sms-laravel without Composer
On this page you can find all versions of the php package amyavari/iran-sms-laravel. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download amyavari/iran-sms-laravel
More information about amyavari/iran-sms-laravel
Files in amyavari/iran-sms-laravel
Package iran-sms-laravel
Short Description A simple and convenient way to send SMS through Iranian SMS providers
License MIT
Homepage https://github.com/amyavari/iran-sms-laravel
Informations about the package iran-sms-laravel
Iran SMS Laravel

A simple and convenient way to send SMS through Iranian SMS providers.
To view the Persian documentation, please refer to README_FA.md.
برای مشاهده راهنمای فارسی، لطفاً به فایل README_FA.md مراجعه کنید.
WARNING: This package is under development. DON'T use it yet.
Requirements
- PHP version
8.2.0
or higher - Laravel
^11.32
, or^12.0.1
List of Available SMS Providers
Provider Name (EN) | Provider Name (FA) | Provider Website | Provider Key | Version |
---|---|---|---|---|
Trez | رایگان اساماس | smspanel.trez.ir | trez |
Unreleased |
Kavenegar | کاوه نگار | kavenegar.com | kavenegar |
Unreleased |
SMS Online | اساماس آنلاین | smsonline.ir | sms_online |
Unreleased |
Magfa | مگفا | magfa.com | magfa |
Unreleased |
Avanak | آوانک | avanak.ir | avanak |
Unreleased |
Installation
To install the package via Composer, run:
Publish Vendor Files
Publish All Files
To publish all vendor files (config and migrations):
Note: To create tables from migrations:
Publish Specific Files
To publish only the config file:
To publish only the migration file:
Note: To create tables from migrations:
Configuration
Single Provider Setup
To configure a single SMS provider, add the following to your .env
file:
Note: For the SMS_PROVIDER
, refer to the Provider Key
column in the List of Available SMS Providers.
Multiple Provider Setup
After publishing the config file (see Publish Vendor Files), you can customize the environment variable names for each provider you want to use. Then, define those variables in your .env
file.
For example, to configure the trez
provider:
Define the corresponding variables in your .env
file:
Usage
Note: This package supports fluent method chaining like Sms::provider()->otp()->log()->send();
, but for simplicity, this manual demonstrates usage with separate instances.
Creating an SMS Instance
You can create an SMS instance using the facade provided by the package:
Note: For the $provider
name, refer to the Provider Key
column in the List of Available SMS Providers.
Automatic Logging
You can chain log configurations on your SMS instance before sending.
To help keep your code clean and logging consistent, especially when managing SMS sending from a central location, this package provides convenient methods to configure logging behavior based on the SMS type and sending status.
Note: Before using any logging features, make sure to create the necessary tables. (See Publish Vendor Files.)
Log Based on SMS Type
Log Based on Sending Status
Note: These methods implicitly enable logging. If you use them without calling a log*()
method first, log(true)
will be applied automatically.
Make Your Log Behavior Fluent
You can chain the logging methods to define custom logic fluently:
Sending SMS
To send the SMS:
Note: This method throws an exception if a client or server error occurs. See the throw
method in HTTP Client.
Checking Sending Status
To check the status after sending:
Working with Queues and Notifications
Queues
To send an SMS instance using queues, you can create an SMS instance and dispatch it to a job where you call the send()
method. You can use the AliYavari\IranSms\Contracts\Sms
interface as a constructor type-hint.
Note: It's recommended to configure log options here to keep your code clean and consistent.
Example:
Notifications
To send SMS using notifications, define a toSms
method in your notification class and return an SMS instance. Also, include AliYavari\IranSms\Channels\SmsChannel
in the via
method.
Note: The toSms
method must return an SMS instance with your log setup (if desired). The channel will handle sending it.
Example:
Testing
This package provides fluent methods to fake and test SMS sending:
Note: Defining both global behavior and per-provider behaviors together is not allowed in a single call. Use one strategy per fake()
call.
Note: If you define multiple behaviors for the same provider, the last one will override the previous definitions.
Contributing
Thank you for considering contributing to the Iran SMS Laravel! The contribution guide can be found in the CONTRIBUTING.md
License
Iran SMS Laravel was created by Ali Mohammad Yavari under the MIT license.
All versions of iran-sms-laravel with dependencies
spatie/laravel-package-tools Version ^1.92
illuminate/contracts Version ^11.32 || ^12.0.1