Download the PHP package gr8shivam/laravel-sms-api without Composer
On this page you can find all versions of the php package gr8shivam/laravel-sms-api. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package laravel-sms-api
Laravel SMS API
A modern, flexible Laravel package for integrating any SMS gateway that provides a REST API. Perfect for Laravel 10+ applications with full support for notifications, multiple gateways, and modern authentication methods.
โญ Star this repo to show support!
๐ Table of Contents
- Features
- Requirements
- Installation
- Quick Start
- Configuration
- Basic Gateway
- Advanced Gateway
- Authentication Methods
- Special Parameters
- Usage
- Helper Function
- Facade
- Notifications
- Advanced Features
- Real Provider Examples
- Testing
- Changelog
- Support
โจ Features
- โ Universal Compatibility - Works with any REST API SMS provider
- โ Multiple Gateways - Configure and switch between multiple SMS providers
- โ Laravel Notifications - Full integration with Laravel's notification system
- โ Modern Auth - Support for Bearer tokens, API keys, Basic Auth, and custom headers
- โ Bulk SMS - Send to multiple recipients in a single call
- โ JSON & Form Data - Support for both JSON payloads and form-encoded requests
- โ Request Wrapping - Handle complex API structures with wrapper support
- โ Type Safe - Built with PHP 8.1+ strict types
- โ Dependency Injection - Modern Laravel service container integration
- โ Comprehensive Logging - Built-in request/response logging
- โ Easy Testing - Mock-friendly architecture
๐ Requirements
- PHP 8.1 or higher
- Laravel 10.x, 11.x, or 12.x
- Guzzle HTTP Client 7.8+
๐ฆ Installation
1. Install via Composer
2. Publish Configuration
This creates config/sms-api.php in your application.
3. Configure Your Gateway
Edit config/sms-api.php and add your SMS provider credentials (see Configuration below).
๐ Quick Start
Send Your First SMS
Send to Multiple Recipients
Get Response
โ๏ธ Configuration
Open config/sms-api.php after publishing.
Global Settings
Basic Gateway Configuration
For simple GET/POST requests:
Advanced Gateway Configuration
For JSON requests with complex structures:
Result payload example:
Authentication Methods
1. Bearer Token (Most Modern APIs)
In .env:
2. API Key in Header
3. Basic Authentication
4. API Key in Parameters
Special Parameters
json (boolean)
Send parameters as JSON payload instead of query string or form data.
jsonToArray (boolean)
When json is true, controls whether a single mobile number is sent as:
true:["9876543210"](array)false:"9876543210"(string)
wrapper (string)
Wraps the JSON request in a named object. Required by some providers.
wrapperParams (array)
Adds parameters inside the wrapper (separate from regular params).
add_code (boolean)
Automatically prepend country code to phone numbers.
๐ฑ Usage
Using Helper Function
The smsapi() helper provides the most convenient way to send SMS.
Basic Usage
With Extra Parameters
With Custom Headers
Using Different Gateway
Using Different Country Code
Bulk SMS
With Wrapper Parameters
Method Chaining
Using Facade
The facade provides the same functionality with explicit imports.
Using Notifications
Laravel SMS API integrates seamlessly with Laravel's notification system.
Step 1: Add Route to Your Model
In your User model (or any Notifiable model):
Step 2: Create Notification
Step 3: Send Notification
Advanced Notification Examples
With Parameters:
With Headers:
Unicode Message:
Using Static Constructor:
Return String (Shorthand):
๐ฅ Advanced Features
1. Safe Sending Helper
Use send_sms() for operations where you want to catch exceptions:
2. Response Handling
3. Message Validation
Enable validation in config:
Then validate:
4. Dynamic Gateway Selection
5. Environment-based Configuration
6. Multiple Recipients Handling
7. Logging
All requests and responses are automatically logged using Laravel's logging system:
๐ Real Provider Examples
Twilio
Usage:
MSG91
Usage:
AWS SNS (via REST API)
Nexmo/Vonage
Generic Bearer Token API
๐งช Testing
Running Tests
Writing Tests
๐ Changelog
See CHANGELOG.md for version history and breaking changes.
Latest Version: 4.0.0
- PHP 8.1+ and Laravel 10+ support
- Modern type hints and strict types
- Bearer token and modern auth support
- Optional message validation
- Enhanced notification system
- Comprehensive test suite
๐ Troubleshooting
SMS Not Sending
- Check logs:
storage/logs/laravel.log - Verify config: Ensure gateway credentials are correct
- Test manually:
Invalid Response
Configuration Not Loading
๐ก Best Practices
- Store credentials in
.env, never hardcode -
Use queued notifications for bulk SMS:
- Implement retry logic for critical messages
- Monitor costs using
estimateSegments() - Test with mock gateway before production
- Log all SMS for audit trail
๐ค Support
- Issues: GitHub Issues
- Documentation: README.md
๐ Credits
Developed by Shivam Agarwal
๐ License
MIT License - see LICENSE file for details.
โญ Show Your Support
If this package helps you, please give it a star on GitHub!
Made with โค๏ธ for the Laravel community
All versions of laravel-sms-api with dependencies
ext-json Version *
ext-mbstring Version *
illuminate/support Version ^10.0|^11.0|^12.0|^13.0
guzzlehttp/guzzle Version ^7.8