twilioman/twilio is a Laravel package for twilio api for laravel.
It currently has 0 GitHub stars and 165 downloads on Packagist (latest version 0.1).
Install it with composer require twilioman/twilio.
Discover more Laravel packages by twilioman
or browse all Laravel packages to compare alternatives.
Last updated
Laravel Twillio API Integration
Begin by installing this package through Composer. Run this command from the Terminal:
composer require twilioman/twilio
If you're using Laravel 5.5+, this is all there is to do.
Should you still be on older versions of Laravel, the final steps for you are to add the service provider of the package and alias the package. To do this open your config/app.php file.
To wire this up in your Laravel project, you need to add the service provider.
Open app.php, and add a new item to the providers array.
'TwilioMan\LaravelTwilio\Provider\ServiceProvider',
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' => 'TwilioMan\LaravelTwilio\Facade\Facade',
First, include the Facade class at the top of your file:
use TwilioMan\LaravelTwilio\Twilio;
To send a message using the default entry from your twilio :
Twilio::message($user->phone, $message);
Creating a Twilio object.
$twilio = new TwilioMan\LaravelTwilio\Twilio($accountId, $token, $fromNumber);
Sending a text message:
$twilio->message('+18085551212', 'Pink Elephants and Happy Rainbows');
Access the configured Twilio\Rest\Client object:
$sdk = $twilio->getTwilio();
You can also access this via the Facade as well:
$sdk = Twilio::getTwilio();
If you want to pass on extra optional parameters to the messages->sendMessage(...) method from the Twilio SDK, 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 arguments on.