A PHP wrapper for Twilio's API

Installs: 12 135 665

Dependents: 170

Suggesters: 10

Security: 0

Stars: 1 179

Watchers: 141

Forks: 460

Open Issues: 12

6.2.0 2020-04-01 19:52 UTC

This package is auto-updated.

Last update: 2020-04-02 21:39:34 UTC


Build Status Packagist Packagist Learn with TwilioQuest


The documentation for the Twilio API can be found here.

The PHP library documentation can be found here.


twilio-php uses a modified version of Semantic Versioning for all changes. See this document for details.

Supported PHP Versions

On January 1, 2020, Twilio will no longer support PHP version 5.X, 7.0, and 7.1 via this helper library. Please see this issue for details.

This library supports the following PHP implementations:

  • PHP 7.2
  • PHP 7.3
  • PHP 7.4


You can install twilio-php via composer or by downloading the source.

Via Composer:

twilio-php is available on Packagist as the twilio/sdk package:

composer require twilio/sdk


Send an SMS

// Send an SMS using Twilio's REST API and PHP
$sid = "ACXXXXXX"; // Your Account SID from
$token = "YYYYYY"; // Your Auth Token from

$client = new Twilio\Rest\Client($sid, $token);
$message = $client->messages->create(
  '8881231234', // Text this number
    'from' => '9991231234', // From a valid Twilio number
    'body' => 'Hello from Twilio!'

print $message->sid;

Make a Call

$sid = "ACXXXXXX"; // Your Account SID from
$token = "YYYYYY"; // Your Auth Token from

$client = new Twilio\Rest\Client($sid, $token);

// Read TwiML at this URL when a call connects (hold music)
$call = $client->calls->create(
  '8881231234', // Call this number
  '9991231234', // From a valid Twilio number
      'url' => ''

Generating TwiML

To control phone calls, your application needs to output TwiML.

Use Twilio\TwiML\(Voice|Messaging|Fax)Response to easily chain said responses.

$response = new Twilio\TwiML\VoiceResponse();
$response->play('', array("loop" => 5));
print $response;

That will output XML that looks like this:

<?xml version="1.0" encoding="utf-8"?>
    <Play loop="5"></Play>

Docker Image

The Dockerfile present in this repository and its respective twilio/twilio-php Docker image are currently used by Twilio for testing purposes only.

Getting help

If you need help installing or using the library, please check the Twilio Support Help Center first, and file a support ticket if you don't find an answer to your question.

If you've instead found a bug in the library or would like new features added, go ahead and open issues or pull requests against this repo!