renderbit / laravel-sms
Framework-agnostic PHP library for sending SMS via Renderbit, with Laravel support.
Requires
- guzzlehttp/guzzle: ^7.0
This package is auto-updated.
Last update: 2025-06-05 13:08:17 UTC
README
A Laravel package to send transactional SMS messages through supported SMS gateways. Built with simplicity, scalability, and performance in mind.
๐ Features
- Simple API to send SMS
- Support for multiple providers (via api-based architecture)
- Queue-friendly and retry-safe
- Customizable sender name and API URL
- Laravel-native configuration and logging
- Facade & dependency injection support
๐ฆ Installation
Install via Composer:
composer require renderbit/laravel-sms
๐ Configuration
Publish the configuration file:
php artisan vendor:publish --tag=sms-config
This will publish config/sms.php
.
Example config/sms.php
:
return return [ 'url' => env('SMS_API_URL', '<default-preconfigured-url>'), 'query_params' => [ 'user' => env('SMS_USER'), 'password' => env('SMS_PASSWORD'), 'senderid' => env('SMS_SENDER_ID', 'IEMUEM'), 'channel' => 'trans', 'DCS' => 0, 'flashsms' => 0, 'route' => '1' ], 'number_field' => env('SMS_NUMBER_FIELD', 'number'), 'message_field' => env('SMS_MESSAGE_FIELD', 'text'), ];;
Update your .env
file:
SMS_USER= SMS_PASSWORD= SMS_SENDER_ID='IEMUEM' SMS_API_URL='http://1.1.1.1/api/SendSMS?' SMS_NUMBER_FIELD='number' SMS_MESSAGE_FIELD='text'
โ๏ธ Usage
You can send an SMS using the facade or the SmsClient
class:
Using Facade
use Sms; Sms::send('+919999999999', 'Hello, your OTP is 123456');
Using Dependency Injection
use Renderbit\Sms\SmsClient; class NotificationService { public function __construct(protected SmsClient $sms) {} public function notify($phone, $message) { $this->sms->send($phone, $message); } }
โ Example Response Handling
The send
method returns a bool
:
$success = Sms::send($phoneNumber, $message); if (!$success) { // Log failure or retry }
๐งช Testing
To fake SMS sending during tests:
Sms::shouldReceive('send') ->once() ->with('+919999999999', 'Test message') ->andReturn(true);
๐ Directory Structure (Core)
SmsClient
: Main entry point, handles sms sending logic.Facades\Sms
: Facade accessor for SmsClient class.config\sms
: Default configs that can be overridden after publishing.SmsServiceProvider
: Auto-discovery and binding.
๐ค Contributing
Pull requests are welcome! For major changes, please open an issue first to discuss what youโd like to change.
๐ License
This package is open-sourced software licensed under the MIT license.
Would you like me to initialize this as a README.md
file inside your package or also help with directory scaffolding like src/SmsClient.php
, Contracts
, etc.?