Download the PHP package beziworld/laravel-twilio without Composer

On this page you can find all versions of the php package beziworld/laravel-twilio. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-twilio

Laravel Twilio

tests Latest Version

Lightweight Laravel integration for Twilio: SMS, MMS and WhatsApp (including content templates and scheduling), Verify, Lookup, basic voice calls, signed webhooks dispatched as Laravel events, a notification channel and multiple accounts.

Polska wersja dokumentacji

Why this package

The official twilio/sdk covers every Twilio product, and laravel-notification-channels/twilio adds a notification channel on top of it. This package takes a different approach:

Installation

Keep TWILIO_AUTH_TOKEN set even when you use an API key: Twilio signs webhooks with the Auth Token.

SMS and MMS

with('ShortenUrls', true) passes any other Message parameter. Fetch, list and manage messages:

Scheduling

Scheduled messages require a Messaging Service and must be 15 minutes to 35 days ahead:

WhatsApp

Recipients and senders receive the whatsapp: prefix automatically.

Verify

verifyCode() returns false for a wrong code and for verifications that expired, were already approved or ran out of attempts (Twilio answers those with HTTP 404). Pass serviceSid: to use another Verify service.

Lookup

Voice and balance

Any other endpoint is available through the generic request helper, authenticated with the connection credentials:

Webhooks

  1. Enable the routes:

    Route Name Purpose
    POST /twilio/webhooks/status twilio.webhooks.status Message status callbacks
    GET\|POST /twilio/webhooks/incoming twilio.webhooks.incoming Incoming SMS and WhatsApp messages
  2. Point Twilio at them: the status URL as StatusCallback (per message or TWILIO_STATUS_CALLBACK) or on the Messaging Service, the incoming URL as "A message comes in" on the number, the WhatsApp sender or the Messaging Service.

  3. Listen to the events:

Without a reply Twilio receives an empty <Response/> and sends nothing. For more control build the TwiML yourself: $event->response()->message('Hi', ['https://example.com/image.jpg'])->redirect('https://example.com/next'). MessagingResponse can also be returned from your own controllers (it is Responsable).

Signature validation

Every webhook request must carry a valid X-Twilio-Signature: an HMAC-SHA1 of the full URL followed by the sorted POST parameters, keyed with the Auth Token. The middleware:

Protect your own Twilio routes, for example voice webhooks, with the same middleware:

The validator can be used directly as well: (new SignatureValidator($authToken))->validate($signature, $url, $request->post()). TWILIO_VALIDATE_SIGNATURE=false disables validation; use it only locally.

Status callbacks may arrive out of order and more than once, so keep listeners idempotent.

Notification channel

The recipient is taken from the notifiable:

On-demand: Notification::route('twilio', '+48500100200')->notify(new OrderShipped($order));

A plain string becomes an SMS. Messages may set their own recipient with ->to() and another account with ->connection('marketing'). A notifiable without a phone number is skipped silently.

Multiple accounts

Define connections in config/twilio.php, like database connections:

Options outside connections (status_callback, timeout, retries, base_urls) are shared and can be overridden per connection.

Error handling

All exceptions extend Beziworld\Twilio\Exceptions\TwilioException:

Exception When
ApiException Twilio rejected the request (errorCode(), httpStatus(), moreInfo(), payload(), isRateLimited(), isNotFound(), isAuthenticationError()) or could not be reached
InvalidMessage Message without recipient, content or sender, template combined with body, scheduling without a Messaging Service
InvalidConfiguration Missing Account SID or credentials, unknown connection, missing Verify service
CouldNotSendNotification Notification without a valid toTwilio()

Retries

Requests rejected with HTTP 429 (error 20429) were not processed by Twilio and are retried TWILIO_RETRIES times (default 2) with exponential backoff. Connection errors are retried only for reads: a message request that timed out may still have been accepted, and repeating it could send the message twice.

Testing your application

Development

Author

Created and maintained by Kamil Ćwiertnia, beziworld.eu.

Need a custom integration or a Laravel project? Get in touch through beziworld.eu.

Other packages by the author

License

MIT. See LICENSE.md. This package is not affiliated with, endorsed by or sponsored by Twilio Inc. "Twilio" and "WhatsApp" are trademarks of their respective owners.


All versions of laravel-twilio with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
ext-json Version *
illuminate/notifications Version ^12.0|^13.0
guzzlehttp/guzzle Version ^7.8
illuminate/contracts Version ^12.0|^13.0
illuminate/http Version ^12.0|^13.0
illuminate/routing Version ^12.0|^13.0
illuminate/support Version ^12.0|^13.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package beziworld/laravel-twilio contains the following files

Loading the files please wait ...