Download the PHP package habeebdev/twilio-webhook-tester without Composer
On this page you can find all versions of the php package habeebdev/twilio-webhook-tester. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package twilio-webhook-tester
Twilio Webhook Tester
PHP wrapper for Twilio CLI webhook plugin - Test Twilio SMS webhooks locally using the Twilio CLI webhook plugin.
Features
- 🚀 Test SMS webhooks locally
- 🔒 Support for secured webhooks (with signature validation)
- 🔓 Support for unsecured webhooks
- 📝 Custom data parameters
- 🌐 GET and POST HTTP methods
- ⚡ Fast and lightweight
- 🔌 Uses official Twilio CLI webhook plugin
- 🎲 Automatic generation of realistic test data using Faker
Prerequisites
This wrapper requires the Twilio CLI and webhook plugin to be installed:
-
Install Twilio CLI:
-
Install Webhook Plugin:
- Verify Installation:
Installation
Usage
Basic Usage
With Custom Data
HTTP Methods
Secured Webhooks
For webhooks that validate the X-Twilio-Signature header:
Option 1: Using .env file (recommended)
Create a .env file in your project root:
Or with API Key/Secret:
Then run:
Option 2: Using command-line arguments
Unsecured Webhooks
For webhooks that don't validate signatures:
Command Options
Automatic Data Generation
The tool automatically generates realistic test data using Faker when parameters are not provided:
Automatically Generated Fields
- MessageSid: Unique SMS message SID (format:
SM...) - SmsMessageSid: Same as MessageSid
- SmsSid: Same as MessageSid
- AccountSid: Random account SID (format:
AC...) - MessagingServiceSid: From
TWILIO_MESSAGING_SERVICE_SIDenv var (if set), otherwise not included - From: Random US phone number (E.164 format) or from
FROM_PHONE_NUMBERenv var - To: Random US phone number (E.164 format) or from
TO_PHONE_NUMBERenv var - Body: Random English message (20-80 characters)
- FromCountry/ToCountry: "US"
- FromState/ToState: Random US state abbreviation
- FromCity/ToCity: Random US city name
- FromZip/ToZip: Random US zip code
- NumMedia: "0"
- SmsStatus: Random from ['received', 'sent', 'delivered']
Overriding Default Values
You can override any automatically generated value using the -d option:
Examples
Example 1: Basic SMS Webhook
Expected output (TwiML):
Example 2: Custom SMS Parameters
Example 3: Testing Protected Webhook
Environment Variables
Important: The Twilio CLI requires authentication. You must set one of the following combinations in your .env file:
Using .env File (Recommended)
Create a .env file in your project root:
Option 1: API Key/Secret (Recommended)
Option 2: Auth Token
Webhook URL (Optional)
Phone Number Defaults (Optional)
Messaging Service SID (Optional)
Quick Setup:
Note:
TWILIO_ACCOUNT_SIDis required for both authentication options- For webhook signature validation, you need either
TWILIO_AUTH_TOKENOR (TWILIO_API_KEY+TWILIO_API_SECRET) WEBHOOK_URLcan be set in.envfile to avoid passing URL as argument each time- Command-line arguments take precedence over
.envfile values - If
FROM_PHONE_NUMBERorTO_PHONE_NUMBERare not set, random phone numbers will be generated TWILIO_MESSAGING_SERVICE_SIDis optional - if not set, it will not be included in the webhook data- The
.envfile is gitignored for security. Never commit your actual credentials to version control.
Requirements
- PHP ^8.0
- Twilio CLI installed and in PATH
- Twilio CLI webhook plugin installed (
@twilio-labs/plugin-webhook) - Node.js (required by Twilio CLI)
License
This project is licensed under the MIT License - see the LICENSE file for details.
Related Resources
Support
For issues and questions:
- Open an issue on GitHub
- Check the Twilio Documentation
Acknowledgments
This project is inspired by the Twilio CLI Webhook Plugin.