PHPackages                             rcalicdan/laravel-sms-api - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. rcalicdan/laravel-sms-api

ActiveLibrary[API Development](/categories/api)

rcalicdan/laravel-sms-api
=========================

Laravel package to provide SMS API integration. Any SMS vendor that provides REST API can be used. SMS-API channel for Laravel notifications also included (this is a forked version).

1.0.0(3mo ago)03MITPHPPHP &gt;=5.6.4

Since Feb 10Pushed 3mo agoCompare

[ Source](https://github.com/rcalicdan/laravel-sms-api-v2)[ Packagist](https://packagist.org/packages/rcalicdan/laravel-sms-api)[ Docs](https://github.com/gr8shivam/laravel-sms-api)[ RSS](/packages/rcalicdan-laravel-sms-api/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (4)Versions (2)Used By (0)

Integrate SMS API with Laravel
==============================

[](#integrate-sms-api-with-laravel)

Laravel package to provide SMS API integration. Any SMS vendor that provides REST API can be used.

Installation
------------

[](#installation)

### Install Package

[](#install-package)

Require this package with composer:

```
composer require rcalicdan/laravel-sms-api

```

### Add Service Provider &amp; Facade

[](#add-service-provider--facade)

#### For Laravel 5.5+

[](#for-laravel-55)

Once the package is added, the service provider and facade will be autodiscovered.

#### For Older versions of Laravel

[](#for-older-versions-of-laravel)

Add the ServiceProvider to the providers array in `config/app.php`:

```
Rcalicdan\SmsApi\SmsApiServiceProvider::class,

```

Add the Facade to the aliases array in `config/app.php`:

```
'SmsApi': Rcalicdan\SmsApi\SmsApiFacade::class,

```

### Publish Config

[](#publish-config)

Once done, publish the config to your config folder using:

```
php artisan vendor:publish --provider="Rcalicdan\SmsApi\SmsApiServiceProvider"

```

Configuration
-------------

[](#configuration)

Once the config file is published, open `config/sms-api.php`

#### Global config

[](#global-config)

`country_code` : The default country code to be used

`default` : Default gateway

#### Gateway Config

[](#gateway-config)

Use can define multiple gateway configs like this:-

```
//    Gateway Configuration
    'gateway_name' => [
        'method' => 'GET', //Choose Request Method (GET/POST) Default:GET
        'url' => 'BaseUrl', //Base URL
        'params' => [
            'send_to_param_name' => '', //Send to Parameter Name
            'msg_param_name' => '', //Message Parameter Name
            'others' => [
                'param1' => '',
                'param2' => '',
                'param3' => '',
                //More params can be added
            ],
        ],
        'headers' => [
            'header1' => '',
            'header2' => '',
            //More headers can be added
        ],
//        'json' => true, // OPTIONAL: Use if you want the params to be sent in JSON format instead of query params (accepts true/false)
//        'wrapper' => 'wrapper_name', // OPTIONAL: Use only if you want the JSON request to be wrapped (accepts string)
        'add_code' => true, //Include Country Code (true/false)
    ],

```

#### Special Parameters in Gateway Config

[](#special-parameters-in-gateway-config)

##### `json` Parameter

[](#json-parameter)

The `json` parameter accepts `true/false`. When `true`, it sends `params` as a JSON payload. It also takes care of `'Content-Type' => 'application/json'` header.

##### `jsonToArray` Parameter

[](#jsontoarray-parameter)

The `jsonToArray` parameter accepts `true/false`. When `true`, it sends a single mobile number in an encapsulated array in the JSON payload. When `false`, a single mobile number is sent as text. Valid only when `json` parameter is `true`.

##### `wrapper` Parameter

[](#wrapper-parameter)

The `wrapper` is a special parameter which will be required only with some gateways. It wraps the JSON payload in the following structure:

```
"wrapper_name": [
    {
      "message": "Message",
      "to": [
        "Receipient1",
        "Receipient2"
      ]
    }
  ]

```

##### `wrapperParams` Parameter

[](#wrapperparams-parameter)

Accepts array. Used to add custom Wrapper Parameters. Parameters can also be added while calling the `smsapi()` function like `smsapi()->addWrapperParams(['wrapperParam1'=>'paramVal'])->sendMessage("TO", "Message")`

Usage
-----

[](#usage)

### Direct Use

[](#direct-use)

Use the `smsapi()` helper function or `SmsApi` facade to send the messages.

`TO`: Single mobile number or Multiple comma-separated mobile numbers

`MESSAGE`: Message to be sent

#### Using Helper function

[](#using-helper-function)

- Basic Usage `smsapi("TO", "Message");` or `smsapi()->sendMessage("TO","MESSAGE");`
- Adding extra parameters `smsapi("TO", "Message", ["param1" => "val"]);` or `smsapi()->sendMessage("TO", "Message", ["param1" => "val"]);`
- Adding extra headers `smsapi("TO", "Message", ["param1" => "val"], ["header1" => "val"]);` or `smsapi()->sendMessage("TO", "Message", ["param1" => "val"], ["header1" => "val"]);`
- Using a different gateway `smsapi()->gateway('GATEWAY_NAME')->sendMessage("TO", "Message");`
- Using a different country code `smsapi()->countryCode('COUNTRY_CODE')->sendMessage("TO", "Message");`
- Sending message to multiple mobiles `smsapi(["Mobile1","Mobile2","Mobile3"], "Message");` or `smsapi()->sendMessage(["Mobile1","Mobile2","Mobile3"],"MESSAGE");`

#### Using SmsApi facade

[](#using-smsapi-facade)

- Basic Usage `SmsApi::sendMessage("TO","MESSAGE");`
- Adding extra parameters `SmsApi::sendMessage("TO", "Message", ["param1" => "val"]);`
- Adding extra headers `SmsApi::sendMessage("TO", "Message", ["param1" => "val"], ["header1" => "val"]);`
- Using a different gateway `SmsApi::gateway('GATEWAY_NAME')->sendMessage("TO", "Message");`
- Using a different country code `SmsApi::countryCode('COUNTRY_CODE')->sendMessage("TO", "Message");`
- Sending message to multiple mobiles `SmsApi::sendMessage(["Mobile1","Mobile2","Mobile3"],"MESSAGE");`

### Use in Notifications

[](#use-in-notifications)

#### Setting up the Route for Notofication

[](#setting-up-the-route-for-notofication)

Add the method `routeNotificationForSmsApi()` to your Notifiable model :

```
public function routeNotificationForSmsApi() {
        return $this->phone; //Name of the field to be used as mobile
    }

```

By default, your User model uses Notifiable.

#### Setting up Notification

[](#setting-up-notification)

Add

`use Rcalicdan\SmsApi\Notifications\SmsApiChannel;`

and

`use Rcalicdan\SmsApi\Notifications\SmsApiMessage;`

to your notification.

You can create a new notification with `php artisan make:notification NOTIFICATION_NAME`

In the `via` function inside your notification, add `return [SmsApiChannel::class];` and add a new function `toSmsApi($notifiable)` to return the message body and parameters.

Notification example:-

```
namespace App\Notifications;

use Rcalicdan\SmsApi\Notifications\SmsApiChannel;
use Rcalicdan\SmsApi\Notifications\SmsApiMessage;
use Illuminate\Notifications\Notification;

class ExampleNotification extends Notification
{
    public function via($notifiable)
    {
        return [SmsApiChannel::class];
    }

    public function toSmsApi($notifiable)
    {
        return (new SmsApiMessage)
            ->content("Hello");
    }
}

```

You can also use `->params(["param1" => "val"])` to add extra parameters to the request and `->headers(["header1" => "val"])` to add extra headers to the request.

### Getting Response

[](#getting-response)

You can get response by using `->response()` or get the Response Code using `->getResponseCode()`. For example, `smsapi()->sendMessage("TO","MESSAGE")->response();`

Support
-------

[](#support)

Feel free to post your issues in the issues section.

Credits
-------

[](#credits)

Developed by [Shivam Agarwal](https://github.com/Rcalicdan "Shivam Agarwal")

Thanks to [laravel-ovh-sms](https://github.com/MarceauKa/laravel-ovh-sms "laravel-ovh-sms") &amp; [softon-sms](https://github.com/softon/sms "softon-sms")

License
-------

[](#license)

MIT

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance82

Actively maintained with recent releases

Popularity3

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity29

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

97d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/adefeba01f7aab9f1eed1cc3f5015be296d86126a4adb50257d81ec0bf23c8ca?d=identicon)[RCalicdan](/maintainers/RCalicdan)

---

Top Contributors

[![rcalicdan](https://avatars.githubusercontent.com/u/163510169?v=4)](https://github.com/rcalicdan "rcalicdan (1 commits)")

---

Tags

laravel-notificationslaravel-smslaravel sms apilaravel sms senderlaravel sms notificationslaravel sms web api

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/rcalicdan-laravel-sms-api/health.svg)

```
[![Health](https://phpackages.com/badges/rcalicdan-laravel-sms-api/health.svg)](https://phpackages.com/packages/rcalicdan-laravel-sms-api)
```

###  Alternatives

[skagarwal/google-places-api

Google Places Api

1913.0M8](/packages/skagarwal-google-places-api)[dcblogdev/laravel-microsoft-graph

A Laravel Microsoft Graph API (Office365) package

168285.5k1](/packages/dcblogdev-laravel-microsoft-graph)[vluzrmos/slack-api

Wrapper for Slack.com WEB API.

102589.1k3](/packages/vluzrmos-slack-api)[jasara/php-amzn-selling-partner-api

A fluent interface for Amazon's Selling Partner API in PHP

1344.8k1](/packages/jasara-php-amzn-selling-partner-api)[grantholle/powerschool-api

A Laravel package to make interacting with PowerSchool less painful.

1715.6k1](/packages/grantholle-powerschool-api)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
