mg-techlegend / laravel-beem-africa
A Laravel package to send SMS using Beem Africa via Laravel notifications
Fund package maintenance!
mg-techlegend
Requires
- php: ^8.4
- illuminate/contracts: ^11.22||^12.0
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- laravel/pint: ^1.14
- nunomaduro/collision: ^8.1.1||^7.10.0
- orchestra/testbench: ^10.0.0||^9.0.0||^8.22.0
- pestphp/pest: ^3.0
- pestphp/pest-plugin-arch: ^3.0
- pestphp/pest-plugin-laravel: ^3.0
README
A Laravel package to send SMS via Beem Africa using Laravel Notifications.
This package provides a simple, elegant way to send SMS messages using Beem Africa's API. It integrates seamlessly with Laravel's native notification system, allowing you to send SMS just like Mail or Slack notifications. Currently, the package supports SMS functionality, with more Beem services (such as OTPs, voice, USSD, and messaging insights) to be added soon.
๐ฆ Installation
You can install the package via Composer:
composer require mg-techlegend/laravel-beem-africa
Then, publish the config file:
php artisan vendor:publish --tag="laravel-beem-africa-config"
Update your .env
file with your Beem credentials:
BEEM_API_KEY=your-api-key BEEM_SECRET_KEY=your-secret BEEM_SENDER_NAME=your-sender-name
๐ Configuration
The config file config/beem.php
will contain:
return [ 'api_key' => env('BEEM_API_KEY'), 'secret_key' => env('BEEM_SECRET_KEY'), 'sender_name' => env('BEEM_SENDER_NAME'), ];
๐ Usage
You can send SMS via Laravelโs notification system like this:
Create a notification:
use Illuminate\Notifications\Notification; use TechLegend\LaravelBeemAfrica\SMS\BeemMessage; class SendSmsNotification extends Notification { public function via($notifiable): array { return ['beem']; } public function toBeem($notifiable): BeemMessage { return new BeemMessage('Your order has been shipped!'); } }
Use in your model:
Make sure your Notifiable
model has a routeNotificationForBeem()
method that returns the recipientโs phone number in array.
public function routeNotificationForBeem(): array { return array($this->phone_number); }
Send the notification:
$user->notify(new SendSmsNotification());
โ Testing
composer test
Tests are written using Pest and run automatically via GitHub Actions on every push.
โ Roadmap
- SMS Notifications
- OTP Support
- USSD Integration
- Message Insights
- Webhooks Support
- Voice Notifications
๐ Changelog
Please see CHANGELOG for more information on what has changed recently.
๐ค Contributing
Contributions are welcome! Please see CONTRIBUTING for details.
๐ Security
If you discover any security issues, please review our security policy to report them.
๐จโ๐ป Credits
๐ License
The MIT License (MIT). Please see the LICENSE file for more information.