Laravel SMS Gateway

Overview

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
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

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

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

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

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 ..

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.

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.

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

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

Owner
Fowitech
Focus with technology
Fowitech
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

Mohammed-Thamnees 3 Apr 15, 2021
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

InfyOmLabs (InfyOm Technologies) 10 Nov 29, 2022
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

Mouad ZIANI 29 Nov 27, 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

Md. Asif Iqbal 1 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

Martin Mulyo Syahidin 25 Dec 4, 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

Muhammad Athhar Kautsar 46 Dec 17, 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

Laravel Lang 6.9k Jan 2, 2023
⚡ 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

Erik C. Forés 31 Dec 18, 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

Sam Rapaport 46 Oct 1, 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

null 9 Dec 14, 2022