A PHP wrapper for Twilio's API


Build Status Packagist Packagist


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.


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 to easily create such responses.

$response = new Twilio\Twiml();
$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>


The documentation for the Twilio API is located here.

The PHP library documentation can be found here.


twilio-php's versioning strategy can be found here.


  • PHP >= 5.3
  • The PHP JSON extension

Getting help

If you need help installing or using the library, please contact Twilio Support at first. Twilio's Support staff are well-versed in all of the Twilio Helper Libraries, and usually reply within 24 hours.

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!