Skip to content

toriqahmads/sms-viro

Repository files navigation

SMS Viro Package for PHP Application

Latest Version on Packagist Build Status Quality Score Total Downloads

Installation

You can install the package via composer:

composer require toriqahmads/sms-viro

Usage

Create an instance of class, pass apikey and sender name

use Toriqahmads\SmsViro\SmsViro;

$smsviro = new SmsViro('707474e01fead92a7c9421a4069f21cd-12969e36-b3ef-46d8-8e93-f78804cee22d', 'YourAwesomeApp');
$smsviro->sendSms('089668639048', 'Your otp code is 6989');
var_dump($smsviro->isRequestSuccess());

Framework Integrations

Laravel

1. Direct in controller

Import package in the top of classname

use Toriqahmads\SmsViro\SmsViro;

In method/function, pass apikey and sender name on instance class. call sendSms to send your message

...
$smsviro = new SmsViro('707474e01fead92a7c9421a4069f21cd-12969e36-b3ef-46d8-8e93-f78804cee22d', 'YourAwesomeApp');
$smsviro->sendSms('089668639048', 'Your otp code is 6989');
$smsviro->isRequestSuccess();
...

2. Dependency Injection

Bind class on register method

...
use Toriqahmads\SmsViro\SmsViro;

class OptimusServiceProvider extends ServiceProvider
{
    public function register()
    {
        ...
        $this->app->singleton(SmsViro::class, function ($app) {
            return new SmsViro('707474e01fead92a7c9421a4069f21cd-12969e36-b3ef-46d8-8e93-f78804cee22d', 'YourAwesomeApp');
        });
    }
...

Example controller

...
use Toriqahmads\SmsViro\SmsViro;

class TestController extends Controller
{
    public function sendSms(SmsViro $smsviro)
    {
        $smsviro->sendSms('089668639048', 'Your otp code is 6989');
        $smsviro->isRequestSuccess();
    }
}
...

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email toriq@edu.unisbank.ac.id instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

PHP Package Boilerplate

This package was generated using the PHP Package Boilerplate.