Laravel SMS Gateway

Last update: Jun 19, 2022

Laravel SMS Gateway

GitHub License Latest Version on Packagist GitHub Tests Action Status Total Downloads

This is a Laravel Package for SMS Gateway Integration. Now Sending SMS is easy.

List of supported gateways:

📦 Install

Via Composer

$ composer require fowitech/laravel-sms

Configure

Publish the config file

$ php artisan sms:publish

In the config file you can set the default driver to use for all your SMS. But you can also change the driver at runtime.

Choose what gateway you would like to use for your application. Then make that as default driver so that you don't have to specify that everywhere. But, you can also use multiple gateways in a project.

// Eg. if you want to use Netgsm.
 'driver' => env('SMS_DRIVER', 'netgsm'),

Then fill the credentials for that gateway in the drivers array.

// Eg. for Netgsm.
'netgsm' => [
    'transport' => \Fowitech\Sms\Drivers\Netgsm::class,
    'sender' => env('NETGSM_SENDER', ''),
    'username' => env('NETGSM_USERNAME', ''),
    'password' => env('NETGSM_PASSWORD', ''),
    'options' => [
        // some options
    ]
],

🔥 Usage

In your code just use it like this.

to(['Number 1', 'Number 2'])->send(); # If you want to use a different driver. Sms::via('gateway')->message("this message")->to(['Number 1', 'Number 2'])->send(); # If you want to use options array $options = [ 'send_date' => now()->addHour() ]; Sms::via('gateway')->message("this message")->to(['Number 1', 'Number 2'])->send($options); # If you are not a Laravel's facade fan, you can use sms helper: sms()->message("this message")->to(['Number 1', 'Number 2'])->send(); # If you want to use a different driver. sms()->via('gateway')->message("this message")->to(['Number 1', 'Number 2'])->send();">
# On the top of the file.
use Sms;

...

# In your Controller.
Sms::message("this message")->to(['Number 1', 'Number 2'])->send();

# If you want to use a different driver.
Sms::via('gateway')->message("this message")->to(['Number 1', 'Number 2'])->send();

# If you want to use options array
$options = [
    'send_date' => now()->addHour()
];
Sms::via('gateway')->message("this message")->to(['Number 1', 'Number 2'])->send($options);

# If you are not a Laravel's facade fan, you can use sms helper:
sms()->message("this message")->to(['Number 1', 'Number 2'])->send();

# If you want to use a different driver.
sms()->via('gateway')->message("this message")->to(['Number 1', 'Number 2'])->send();

😍 Channel Usage

First you have to create your notification using php artisan make:notification command. then SmsChannel::class can be used as channel like the below:

namespace App\Notifications;

use Illuminate\Bus\Queueable;
use Fowitech\Sms\Channels\SmsChannel;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;

class InvoicePaid extends Notification
{
    use Queueable;

    /**
     * Get the notification channels.
     *
     * @param  mixed  $notifiable
     * @return array|string
     */
    public function via($notifiable)
    {
        return [SmsChannel::class];
    }

    /**
     * Get the recipients and body of the notification.
     *
     * @param  mixed  $notifiable
     * @return Builder
     */
    public function toSms($notifiable)
    {
        return "Sms message";
    }
}

Custom Made Driver, How To:

First you have to name your driver in the drivers array and also you can specify any config params you want.

'my_driver' => [
    'transport' => \App\Packages\SMSDriver\MyDriver::class,
    'sender' => env('MYDRIVER_SENDER', ''),
    'username' => env('MYDRIVER_USERNAME', ''),
    'password' => env('MYDRIVER_PASSWORD', ''),
    'options' => [
        // some options
    ]
    ... # Your Config Params here.
]

Ex. You created a class : App\Packages\SMSDriver\MyDriver.

namespace App\Packages\SMSDriver;

use Fowitech\Sms\Drivers\Driver;

class MyDriver extends Driver 
{
    public function __construct($options = [])
    {
        $this->sender = config('sms.my_driver.sender');
        $this->username = config('sms.my_driver.username');
        $this->password = config('sms.my_driver.password');
        $this->client = $this->getInstance();
    }

    public function send($options = [])
    {
        # Main logic of Sending SMS.
    }
}

🔬 Testing

composer test

GitHub

https://github.com/fowitech/laravel-sms
You might also like...

Laravel Segment is an opinionated, approach to integrating Segment into your Laravel application.

Laravel Segment Laravel Segment is an opinionated, approach to integrating Segment into your Laravel application. Installation You can install the pac

May 16, 2022

Laravel Sanctum support for Laravel Lighthouse

Laravel Sanctum support for Laravel Lighthouse

Lighthouse Sanctum Add Laravel Sanctum support to Lighthouse Requirements Installation Usage Login Logout Register Email Verification Forgot Password

Aug 4, 2022

Bring Laravel 8's cursor pagination to Laravel 6, 7

Laravel Cursor Paginate for laravel 6,7 Installation You can install the package via composer: composer require vanthao03596/laravel-cursor-paginate U

Jan 13, 2022

A package that uses blade templates to control how markdown is converted to HTML inside Laravel, as well as providing support for markdown files to Laravel views.

A package that uses blade templates to control how markdown is converted to HTML inside Laravel, as well as providing support for markdown files to Laravel views.

Install Install via composer. $ composer require olliecodes/laravel-etched-blade Once installed you'll want to publish the config. $ php artisan vendo

Jul 5, 2021

A light weight laravel package that facilitates dealing with arabic concepts using a set of classes and methods to make laravel speaks arabic

A light weight laravel package that facilitates dealing with arabic concepts using a set of classes and methods to make laravel speaks arabic! concepts like , Hijri Dates & Arabic strings and so on ..

Jun 22, 2022

Jetstrap is a lightweight laravel 8 package that focuses on the VIEW side of Jetstream / Breeze package installed in your Laravel application

A Laravel 8 package to easily switch TailwindCSS resources generated by Laravel Jetstream and Breeze to Bootstrap 4.

Aug 7, 2022

Laravel Jetstream is a beautifully designed application scaffolding for Laravel.

Laravel Jetstream is a beautifully designed application scaffolding for Laravel. Jetstream provides the perfect starting point for your next Laravel application and includes login, registration, email verification, two-factor authentication, session management, API support via Laravel Sanctum, and optional team management.

Aug 9, 2022

Laravel Larex lets you translate your whole Laravel application from a single CSV file.

Laravel Larex lets you translate your whole Laravel application from a single CSV file.

Laravel Larex Translate Laravel Apps from a CSV File Laravel Larex lets you translate your whole Laravel application from a single CSV file. You can i

Jul 5, 2022

A Laravel package that adds a simple image functionality to any Laravel model

A Laravel package that adds a simple image functionality to any Laravel model

Laraimage A Laravel package that adds a simple image functionality to any Laravel model Introduction Laraimage served four use cases when using images

Jul 17, 2022
Razorpay payment gateway integration in laravel with submit form and storing details in payment table.

Integrating razorpay payment gateway in laravel with submit form and storing payment details in payment table. How to settup the project in your local

Apr 15, 2021
PayuMoney Gateway wrapper for Laravel.
PayuMoney Gateway wrapper for Laravel.

PayuMoney Integration with Laravel Easy to use integration for PayUMoney into Laravel apps. Video Tutorial Usage composer require infyomlabs/laravel-p

Mar 2, 2022
A laravel wrapper for BnpParibas Mercanet payment gateway
A laravel wrapper for BnpParibas Mercanet payment gateway

Laravel Mercanet A laravel wrapper for BnpParibas Mercanet which provide a lightweight public api to process your online payments from your laravel ap

Jul 3, 2022
SSLCommerz Payment gateway library for Laravel framework

SSLCommerz SSLCommerz Payment gateway library for Laravel framework. Official documentation is here. install composer require sam-asif/sslcommerz Pro

Oct 28, 2021
Integrasi Payment Gateway Midtrans dengan Framework Laravel 8

About Laravel Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experie

Aug 12, 2022
Backend application using Laravel 9.x REST APIs for games topup from digiflazz.com and payment gateway using xendit.co

TOPUP - Laravel 9.x REST API Documentation is still on progress. For now, you can fork this postman collection Installation Clone this project git clo

Jul 31, 2022
List of 77 languages for Laravel Framework 4, 5, 6, 7 and 8, Laravel Jetstream , Laravel Fortify, Laravel Breeze, Laravel Cashier, Laravel Nova and Laravel Spark.

Laravel Lang In this repository, you can find the lang files for the Laravel Framework 4/5/6/7/8, Laravel Jetstream , Laravel Fortify, Laravel Cashier

Aug 10, 2022
⚡ Laravel Charts — Build charts using laravel. The laravel adapter for Chartisan.
⚡ Laravel Charts — Build charts using laravel. The laravel adapter for Chartisan.

What is laravel charts? Charts is a Laravel library used to create Charts using Chartisan. Chartisan does already have a PHP adapter. However, this li

Aug 11, 2022
Laravel Kickstart is a Laravel starter configuration that helps you build Laravel websites faster.

Laravel Kickstart What is Laravel Kickstart? Laravel Kickstart is a Laravel starter configuration that helps you build Laravel websites faster. It com

Jan 8, 2022
Laravel User Activity Log - a package for Laravel 8.x that provides easy to use features to log the activities of the users of your Laravel app
Laravel User Activity Log - a package for Laravel 8.x that provides easy to use features to log the activities of the users of your Laravel app

Laravel User Activity Log - a package for Laravel 8.x that provides easy to use features to log the activities of the users of your Laravel app

Jul 7, 2022