PHP – a recap
We've already worked with the PHP library in Chapter 2, Exploring the REST API, but it's worth a quick recap so we can see more clearly how it compares with libraries in the other languages we'll be looking at.
To get a hold of the PHP library, we can manually download its source and include it into our project ourselves. However, it's much better to use Composer, which is a dependency management tool for PHP.
First, you'll need to install Composer for your platform. Follow the instructions at https://getcomposer.org/doc/00-intro.md to get up and running.
Once Composer is set up, simply run this in your project directory:
composer require twilio/sdk dev-master
This will create a composer.json
file for you to record your and then will add the Twilio library to this file, download the library and all of its dependencies, and generate an autoload.php
file.
Now that the library is installed into our project, we can set up the client as follows:
<?php // Require Composer's autoload...