therealsmat / laravel-ebulksms
:Laravel wrapper around e-bulk sms api
Installs: 10 291
Dependents: 0
Suggesters: 0
Security: 0
Stars: 8
Watchers: 2
Forks: 6
Open Issues: 1
Requires
- php: ~5.6|~7.0
- guzzlehttp/guzzle: ^6.3
- illuminate/support: ~5.1
Requires (Dev)
- phpunit/phpunit: >=5.4.3
- squizlabs/php_codesniffer: ^2.3
This package is not auto-updated.
Last update: 2024-12-22 07:11:39 UTC
README
A package built to allow Nigerian laravel developers easily send sms from their application.
Requirements
PHP 5.4+, Composer are required.
Installation
You need to be have an Ebulk account to use this package. If you do not have one, click here.
Require the package with composer.
$ composer require therealSMAT/laravel-ebulksms
You might need to add therealsmat\Ebulksms\EbulkSmsServiceProvider::class,
to the providers array config/app.php
if your laravel version is less than 5.5.
Laravel 5.5 uses Package Auto-Discovery, so doesn't require you to manually add the ServiceProvider.
Configuration
Publish the configuration file by using this command
php artisan vendor:publish --provider="therealsmat\Ebulksms\EbulkSmsServiceProvider"
You will get a config file named ebulksms.php
in your config directory. Customize the defaults to your ebulk sms settings.
<?php return [ /** * Your login username on eBulkSMS (same as your email address) */ 'username' => getenv('EBULK_USERNAME'), /** * Your Ebulk SMS Api Key */ 'apiKey' => getenv('EBULK_API_KEY'), /** * Your chosen sender name */ 'sender' => getenv('EBULK_SENDER_NAME'), /** * Country code to be appended to each phone number */ 'country_code' => '234' ];
Usage
Add the following to your .env file
EBULK_USERNAME=*********** EBULK_API_KEY=************ EBULK_SENDER_NAME=********
Create a route endpoint
Route::get('/sms', 'HomeController@index');
For a text message
<?php namespace App\Http\Controllers; use Illuminate\Http\Request; use therealsmat\Ebulksms\EbulkSMS; class HomeController extends Controller { public function index(EbulkSMS $sms) { $message = 'Hello world!'; $recipients = '0701********'; return $sms->composeMessage($message) ->addRecipients($recipients) ->send(); } }
For a flash message
<?php namespace App\Http\Controllers; use Illuminate\Http\Request; use therealsmat\Ebulksms\EbulkSMS; class HomeController extends Controller { public function index(EbulkSMS $sms) { $message = 'Hello world!'; $recipients = '0701********'; return $sms->composeMessage($message) ->addRecipients($recipients) ->flash(); } }
For balance enquiry
<?php namespace App\Http\Controllers; use Illuminate\Http\Request; use therealsmat\Ebulksms\EbulkSMS; class HomeController extends Controller { public function index(EbulkSMS $sms) { return $sms->getBalance(); } }
License
The MIT License (MIT). Please see License File for more information.