PHPackages                             fleetbase/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. fleetbase/twilio

ActiveLibrary[API Development](/categories/api)

fleetbase/twilio
================

Twilio API for Laravel

5.0.1(1y ago)219.3k↑14%31MITPHP &gt;=7.2.0

Since May 8Pushed 1y agoCompare

[ Source](https://github.com/fleetbase/laravel-twilio)[ Packagist](https://packagist.org/packages/fleetbase/twilio)[ Docs](https://github.com/fleetbase/laravel-twilio)[ GitHub Sponsors](https://github.com/sponsors/hannesvdvreken)[ RSS](/packages/fleetbase-twilio/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (5)Versions (3)Used By (1)

laravel-twilio
==============

[](#laravel-twilio)

Laravel Twilio API Integration

[![Build Status](https://camo.githubusercontent.com/37f39e9dc51926514b2e177509cba025ee096e7651727e2a50cc74b1d45a5fb5/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f666c656574626173652f6c61726176656c2d7477696c696f2e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/fleetbase/laravel-twilio)[![Total Downloads](https://camo.githubusercontent.com/3297822c29ebe746e8e8203471f0fc611e0bff39e9913e05b7995bcc4fb4faf2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f666c656574626173652f7477696c696f2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/fleetbase/twilio)[![Latest Stable Version](https://camo.githubusercontent.com/087b584124984ee045e0c55f69027282d619cbeaf5aa42a2942c2875446f719f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f666c656574626173652f7477696c696f2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/fleetbase/twilio)[![License](https://camo.githubusercontent.com/f84f889d59140c2acf4feffb0b8d9e960ef23e9b4e2ea5c716c70cdec7d328bb/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f666c656574626173652f6c61726176656c2d7477696c696f3f7374796c653d666c61742d737175617265)](#license)

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

[](#installation)

Begin by installing this package through Composer. Run this command from the Terminal:

```
composer require fleetbase/twilio
```

This will register two new artisan commands for you:

- `twilio:sms`
- `twilio:call`

And make these objects resolvable from the IoC container:

- `Fleetbase\Twilio\Manager` (aliased as `twilio`)
- `Fleetbase\Twilio\TwilioInterface` (resolves a `Twilio` object, the default connection object created by the `Manager`).

There's a Facade class available for you, if you like. In your `app.php` config file add the following line to the `aliases` array if you want to use a short class name:

```
'Twilio' => 'Fleetbase\Twilio\Support\Laravel\Facade',
```

You can publish the default config file to `config/twilio.php` with the terminal command

```
php artisan vendor:publish --provider="Fleetbase\Twilio\Support\Laravel\ServiceProvider"
```

#### Facade

[](#facade)

The facade has the exact same methods as the `Fleetbase\Twilio\TwilioInterface`. First, include the `Facade` class at the top of your file:

```
use Twilio;
```

To send a message using the default entry from your `twilio` [config file](src/config/config.php):

```
Twilio::message($user->phone, $message);
```

One extra feature is that you can define which settings (and which sender phone number) to use:

```
Twilio::from('call_center')->message($user->phone, $message);
Twilio::from('board_room')->message($boss->phone, 'Hi there boss!');
```

Define multiple entries in your `twilio` [config file](src/config/config.php) to make use of this feature.

### Usage

[](#usage)

Creating a Twilio object. This object implements the `Fleetbase\Twilio\TwilioInterface`.

```
$twilio = new Fleetbase\Twilio\Twilio($accountId, $token, $fromNumber);
```

Sending a text message:

```
$twilio->message('+18085551212', 'Pink Elephants and Happy Rainbows');
```

Creating a call:

```
$twilio->call('+18085551212', 'http://foo.com/call.xml');
```

Generating a call and building the message in one go:

```
$twilio->call('+18085551212', function (\Twilio\TwiML\VoiceResponse $message) {
    $message->say('Hello');
    $message->play('https://api.twilio.com/cowbell.mp3', ['loop' => 5]);
});
```

or to make a call with *any* Twiml description you can pass along any Twiml object:

```
$message = new \Twilio\TwiML\VoiceResponse();
$message->say('Hello');
$message->play('https://api.twilio.com/cowbell.mp3', ['loop' => 5]);

$twilio->call('+18085551212', $message);
```

Access the configured `Twilio\Rest\Client` object:

```
$sdk = $twilio->getTwilio();
```

You can also access this via the Facade as well:

```
$sdk = Twilio::getTwilio();
```

##### Pass as many optional parameters as you want

[](#pass-as-many-optional-parameters-as-you-want)

If you want to pass on extra optional parameters to the `messages->sendMessage(...)` method [from the Twilio SDK](https://www.twilio.com/docs/api/messaging/send-messages), you can do so by adding to the `message` method. All arguments are passed on, and the `from` field is prepended from configuration.

```
$twilio->message($to, $message, $mediaUrls, $params);
// passes all these params on.
```

The same is true for the [call method](https://www.twilio.com/docs/api/voice/call#post-parameters).

```
$twilio->call($to, $message, $params);
// passes all these params on.
```

#### Dummy class

[](#dummy-class)

There is a dummy implementation of the `TwilioInterface` available: `Fleetbase\Twilio\Dummy`. This class allows you to inject this instead of a working implementation in case you need to run quick integration tests.

#### Logging decorator

[](#logging-decorator)

There is one more class available for you: the `Fleetbase\Twilio\LoggingDecorator`. This class wraps any `TwilioInterface` object and logs whatever Twilio will do for you. It also takes a `Psr\Log\LoggerInterface` object (like Monolog) for logging, you know.

By default the service providers don't wrap objects with the `LoggingDecorator`, but it is at your disposal in case you want it. A possible use case is to construct a `TwilioInterface` object that logs what will happen, but doesn't actually call Twilio (using the Dummy class):

```
if (getenv('APP_ENV') === 'production') {
    $twilio = $container->make(\Fleetbase\Twilio\Manager::class);
} else {
    $psrLogger = $container->make(\Psr\Log\LoggerInterface::class);
    $twilio = new LoggingDecorator($psrLogger, new \Fleetbase\Twilio\Dummy());
}

// Inject it wherever you want.
$notifier = new Notifier($twilio);
```

Credits
-------

[](#credits)

- [Hannes Van De Vreken](https://twitter.com/hannesvdvreken)
- [Travis Ryan](https://twitter.com/nayrsivart)
- [All Contributors](../../contributors)

### License

[](#license)

laravel-twilio is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT)

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance34

Infrequent updates — may be unmaintained

Popularity32

Limited adoption so far

Community25

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

 Bus Factor1

Top contributor holds 58.9% 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 ~98 days

Total

2

Last Release

641d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9350b92834554a15fb0fff7c7c73750c86a5edd5038e4f0006f8b888a9379b57?d=identicon)[fleetbase](/maintainers/fleetbase)

---

Top Contributors

[![hannesvdvreken](https://avatars.githubusercontent.com/u/1410358?v=4)](https://github.com/hannesvdvreken "hannesvdvreken (132 commits)")[![aloha](https://avatars.githubusercontent.com/u/1420569?v=4)](https://github.com/aloha "aloha (40 commits)")[![andyfleming](https://avatars.githubusercontent.com/u/721038?v=4)](https://github.com/andyfleming "andyfleming (8 commits)")[![reedmaniac](https://avatars.githubusercontent.com/u/1033071?v=4)](https://github.com/reedmaniac "reedmaniac (7 commits)")[![RDelorier](https://avatars.githubusercontent.com/u/2295675?v=4)](https://github.com/RDelorier "RDelorier (4 commits)")[![kodjunkie](https://avatars.githubusercontent.com/u/21959017?v=4)](https://github.com/kodjunkie "kodjunkie (3 commits)")[![coffe4u](https://avatars.githubusercontent.com/u/2783407?v=4)](https://github.com/coffe4u "coffe4u (3 commits)")[![roncodes](https://avatars.githubusercontent.com/u/816371?v=4)](https://github.com/roncodes "roncodes (3 commits)")[![tomschlick](https://avatars.githubusercontent.com/u/70184?v=4)](https://github.com/tomschlick "tomschlick (2 commits)")[![nikolajlovenhardt](https://avatars.githubusercontent.com/u/3541622?v=4)](https://github.com/nikolajlovenhardt "nikolajlovenhardt (2 commits)")[![shahvirag](https://avatars.githubusercontent.com/u/24240840?v=4)](https://github.com/shahvirag "shahvirag (2 commits)")[![idleup](https://avatars.githubusercontent.com/u/1878658?v=4)](https://github.com/idleup "idleup (2 commits)")[![anasterism](https://avatars.githubusercontent.com/u/6999259?v=4)](https://github.com/anasterism "anasterism (2 commits)")[![mickaelandrieu](https://avatars.githubusercontent.com/u/1247388?v=4)](https://github.com/mickaelandrieu "mickaelandrieu (1 commits)")[![Norris1z](https://avatars.githubusercontent.com/u/18237132?v=4)](https://github.com/Norris1z "Norris1z (1 commits)")[![olsgreen](https://avatars.githubusercontent.com/u/1324164?v=4)](https://github.com/olsgreen "olsgreen (1 commits)")[![philnash](https://avatars.githubusercontent.com/u/31462?v=4)](https://github.com/philnash "philnash (1 commits)")[![rap2hpoutre](https://avatars.githubusercontent.com/u/1575946?v=4)](https://github.com/rap2hpoutre "rap2hpoutre (1 commits)")[![Atrophius](https://avatars.githubusercontent.com/u/260725?v=4)](https://github.com/Atrophius "Atrophius (1 commits)")[![russmatney](https://avatars.githubusercontent.com/u/1596350?v=4)](https://github.com/russmatney "russmatney (1 commits)")

---

Tags

laravelsmstwilioivr

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/fleetbase-twilio/health.svg)

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

###  Alternatives

[aloha/twilio

Twilio API for Laravel

4733.6M5](/packages/aloha-twilio)[laravel-notification-channels/twilio

Provides Twilio notification channel for Laravel

2587.7M12](/packages/laravel-notification-channels-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)
