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.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package iran-sms-laravel

Iran SMS Laravel

PHP Version Laravel Version Packagist Version Packagist Downloads Packagist License Tests

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 مراجعه کنید.

Requirements

List of Available SMS Providers

Provider Name (EN) Provider Name (FA) Provider Website Provider Key Version
SMS.ir اس ام اس دات آی آر sms.ir sms_ir 1.0.0
Meli Payamak ملی پیامک melipayamak.com meli_payamak 1.0.0
Payam Resan پیام رسان payam-resan.com payam_resan 1.0.0
Kavenegar کاوه نگار kavenegar.com kavenegar 1.0.0
Faraz SMS فراز اس ام اس farazsms.com faraz_sms 1.0.0
Raygan SMS رایگان اس ام اس raygansms.com raygan_sms 1.0.0
Web One SMS وب وان webone-sms.com web_one 1.1.0
Amoot SMS پیامک آموت amootsms.com amoot_sms 1.1.0

[!CAUTION] Providers have different rules for sending SMS messages. Please check providers_note_en.md.

Table of Content

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.

Changing the Sender Number at Runtime

To send an SMS from a number other than the default SMS_FROM, use the from() method when building your message:

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:

Prune Old Logs

To help keep your log table clean, this package provides an Artisan command to prune old log records. You can schedule this command using Laravel's task scheduler

Example: Delete logs created before 30 days ago

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. This file provides a step-by-step guide to easily add a new driver (SMS provider) to the package.

License

Iran SMS Laravel was created by Ali Mohammad Yavari under the MIT license.


All versions of iran-sms-laravel with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
spatie/laravel-package-tools Version ^1.92
illuminate/contracts Version ^11.35.1 || ^12.0.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package amyavari/iran-sms-laravel contains the following files

Loading the files please wait ....