PHPackages                             i-rocky/laravel-twilio - 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. i-rocky/laravel-twilio

ActiveLibrary[API Development](/categories/api)

i-rocky/laravel-twilio
======================

Twilio Fax, SMS, MMS, Voice Call recording, receiving, sending support for laravel

1.1.0(6y ago)445MITPHPCI failing

Since Nov 17Pushed 6y ago2 watchersCompare

[ Source](https://github.com/i-rocky/laravel-twilio)[ Packagist](https://packagist.org/packages/i-rocky/laravel-twilio)[ RSS](/packages/i-rocky-laravel-twilio/feed)WikiDiscussions master Synced yesterday

READMEChangelog (3)Dependencies (3)Versions (4)Used By (0)

laravel-twilio
--------------

[](#laravel-twilio)

### Installation

[](#installation)

Run the following commands

`composer require i-rocky/laravel-twilio`

`php artisan laravel-twilio:install`

This should publish the following files

```
project
└───config
|       laravel-twilio.php
|
└───resources
    └───assets
        └───js
            └───vendor
                └───laravel-twilio
                    └───mappers
                    |       ResponseMapper.js //maps the response into Response instance
                    |
                    └───models
                    |       Response.js //response model
                    |
                    └───services
                            HttpService.js //proxy for axios requests
                            TwilioService.js //wrapper for twilio client

```

> To use `TwilioService.js` run `yarn add axios twilio-client`

You can add/update/remove/move the files and use as your wish

### Setup

[](#setup)

Update `config/services.php`

```
...
    'twilio' => [
        'account_sid' => env('TWILIO_ACCOUNT_SID'),
        'auth_token'  => env('TWILIO_AUTH_TOKEN'),
        'caller_id'   => env('TWILIO_NUMBER'),
        'username'    => env('TWILIO_USERNAME'),
        'password'    => env('TWILIO_PASSWORD'),
        'app_sid'     => env('TWIML_APP_SID'),
    ],
...
```

Update `.env`

```
TWILIO_ACCOUNT_SID=
TWILIO_AUTH_TOKEN=
TWILIO_NUMBER=
TWIML_APP_SID=

LARAVEL_TWILIO_BASE_URL=laravel-twilio
LARAVEL_TWILIO_ENABLE_CALL=true
LARAVEL_TWILIO_RECORD_CALL=true
LARAVEL_TWILIO_REJECT_CALL_MESSAGE="Thank you for calling us"
LARAVEL_TWILIO_REPLY_MESSAGE=null
MIX_LARAVEL_TWILIO_BASE_URL="${LARAVEL_TWILIO_BASE_URL}"
```

- `TWIML_APP_SID` - you need to create a TwiML app for calling from browser
- `LARAVEL_TWILIO_BASE_URL` - URL prefix for laravel-twilio
- `LARAVEL_TWILIO_REJECT_CALL_MESSAGE` - reject incoming calls with this message when calling is disabled
- `LARAVEL_TWILIO_REPLY_MESSAGE` - reply to incoming messages, null for no reply

Now you have to set the Webhook URL in Twilio console.

> Replace `laravel-twilio` in the Webhook URL with the base URL you've set for `LARAVEL_TWILIO_BASE_URL` in `.env`

#### Incoming Calls

[](#incoming-calls)

Go to your phone number configuration from [Active Numbers](https://www.twilio.com/console/phone-numbers/incoming) then click on the desired number.

1. Under `Voice & Fax` for `Accept Incoming` select `Voice Calls`
2. Under `Configure With` select `Webhooks, TwiML Bins, Functions, Studio, or Proxy`
3. Under `A Call Comes In` select `Webhook` and set the value to `https://your-domain.tld/api/laravel-twilio/voice/incoming`

#### Incoming Faxes

[](#incoming-faxes)

Go to your phone number configuration from [Active Numbers](https://www.twilio.com/console/phone-numbers/incoming) then click on the desired number.

1. Under `Voice & Fax` for `Accept Incoming` select `Faxes`
2. Under `Configure With` select `Webhooks, TwiML Bins, Functions, Studio, or Proxy`
3. Under `A Fax Comes In` select `Webhook` and set the value to `https://your-domain.tld/api/laravel-twilio/fax/incoming`

#### Incoming Messages

[](#incoming-messages)

Go to your phone number configuration from [Active Numbers](https://www.twilio.com/console/phone-numbers/incoming) then click on the desired number.

1. Under `Configure With` select `Webhooks, TwiML Bins, Functions, Studio, or Proxy`
2. Under `A Message Comes In` select `Webhook` and set the value to `https://your-domain.tld/api/laravel-twilio/message/incoming`

#### Outgoing Calls

[](#outgoing-calls)

Go to [TwiML Apps](https://www.twilio.com/console/phone-numbers/runtime/twiml-apps) list and select desired app or create a new app

1. Under `Voice` set the `REQUEST URI` to `https://your-domain.tld/api/laravel-twilio/voice`

### Usage

[](#usage)

Implement `Notifiable`

```
/**
 * @property string username
 * @property string phone
 * @property string phone_number
 */
clas User extends Authenticable {
    use Notifiable;

...

    public function routeNotificationForTwilio() {
        return "+{$this->phone}";
    }

    public function laravelTwilioIdentity() {
        return Str::snake($this->first_name);
    }
}
```

Implement notification

```
use Rocky\LaravelTwilio\Foundation\TwilioMessage;
use Rocky\LaravelTwilio\Message\TwilioSMSMessage;
use Rocky\LaravelTwilio\Message\TwilioMMSMessage;
use Rocky\LaravelTwilio\Message\TwilioFaxMessage;
use Rocky\LaravelTwilio\Message\TwilioCallMessage;
use Rocky\LaravelTwilio\TwilioChannel;

class TwilioTestNotification extends Notification {

...

    public function via($notifiable) {
        return [TwilioChannel::class];
    }

...

    public function toTwilio($notifiable) {
        // SMS
        return (new TwilioSMSMessage())
            ->to('+receiver') // optional
            ->from('+sender') // optional
            ->text('Your message'); // required

        // MMS (only works for Canada and US number)
        return (new TwilioMMSMessage())
            ->to('+receiver') // optional
            ->from('+sender') // optional
            ->text('Your message') // optional
            ->mediaUrl('publicly accessible media url'); // required

        // Call
        return (new TwilioCallMessage())
            ->to('+receiver') // optional
            ->from('+sender') // optional
            ->mediaUrl('publicly accessible media'); // required

        // Fax
        return (new TwilioSMSMessage())
            ->to('+receiver') // optional
            ->from('+sender') // optional
            ->mediaUrl('publicly accessible media url'); // required
    }
}
```

> If you don't use the `to('+number')` method in your message construction, you must have `phone`, `phone_number` property or `routeNotificationForTwilio()` method implemented in your `Notifiable` implementation. The number must start with `+` followed by country code.

> If you don't have `username` property definition in your Auth provider model, you must implement `laravelTwilioIdentity()` method to give your agents an identity for calling.

### Events

[](#events)

Namespace `Rocky\LaravelTwilio\Events`

- `LaravelTwilioIncomingMessage::class` \[gives access to `IncomingMessage` at `$event->getMessage()`\]
- `LaravelTwilioIncomingFax::class` \[gives access to `IncomingFax` at `$event->getFax()`\]
- `LaravelTwilioMessageSent::class` \[gives access to `InstanceResource` at `$event->getMessage()` and `$notifiable` at `$event->getNotifiable()`\]
- `LaravelTwilioMessageSendingFailed::class` \[gives access to `Exception` at `$event->getException()`, `Notification` at `$event->getNotification()`, `$notifiable` at `$event->getNotifiable()`\]
- `LaravelTwilioMessageDeliveryReport::class` \[gives access to `MessageDeliveryReport` at `$event->getReport()`\]
- `LaravelTwilioFaxDeliveryReport::class` \[gives access to `FaxDeliveryReport` at `$event->getReport()`\]
- `LaravelTwilioInboundCall::class` \[gives access to `InboundCall` at `$event->getCall()`\]
- `LaravelTwilioInboundCallRejected::class` \[gives access to `InboundCall` at `$event->getCall()`\]
- `LaravelTwilioOutboundCall::class` \[gives access to `OutboundCall` at `$event->getCall()`\]
- `LaravelTwilioCallStatusUpdate::class` \[gives access to `CallStatus` at `$event->getStatus()`\]
- `LaravelTwilioCallRecord::class` \[gives access to `CallRecord` at `$event->getRecord()`\]

All the parameters sent by Twilio are available in the instance passed through Event. Some of the frequently used properties are added for autocomplete support.

Example:

```
$call = $event->getCall();

$sid = $call->CallSid;
$sid = $call->callSid;
$sid = $call->call_sid;

$from = $call->From;
$from = $call->from;

$allParams = $call->all();
```

> \###*The incoming fax implementation is not tested.*

Look into the source code for a clearer understanding.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 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

Every ~6 days

Total

3

Last Release

2355d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/abb252f726ea7eb04e2824ab0708ee30b282527b3e0f48a8607d3e26510cd6d8?d=identicon)[i-rocky](/maintainers/i-rocky)

---

Top Contributors

[![i-rocky](https://avatars.githubusercontent.com/u/12933820?v=4)](https://github.com/i-rocky "i-rocky (36 commits)")

---

Tags

callincoming-faxesincoming-webhookslaravel-twiliosmstwiliotwilio-apitwilio-api-wrapper

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/i-rocky-laravel-twilio/health.svg)

```
[![Health](https://phpackages.com/badges/i-rocky-laravel-twilio/health.svg)](https://phpackages.com/packages/i-rocky-laravel-twilio)
```

###  Alternatives

[aloha/twilio

Twilio API for Laravel

4733.6M5](/packages/aloha-twilio)[signalwire-community/signalwire

Client library for connecting to SignalWire.

23126.2k](/packages/signalwire-community-signalwire)

PHPackages © 2026

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