https://github.com/matthewbdaly/laravel-sms
SMS service provider for Laravel
https://github.com/matthewbdaly/laravel-sms
laravel php sms
Last synced: 7 months ago
JSON representation
SMS service provider for Laravel
- Host: GitHub
- URL: https://github.com/matthewbdaly/laravel-sms
- Owner: matthewbdaly
- License: mit
- Created: 2017-09-23T17:21:17.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-11-10T13:54:37.000Z (over 7 years ago)
- Last Synced: 2024-11-12T23:39:43.726Z (7 months ago)
- Topics: laravel, php, sms
- Language: PHP
- Size: 50.8 KB
- Stars: 35
- Watchers: 3
- Forks: 11
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# laravel-sms
[](https://travis-ci.org/matthewbdaly/laravel-sms)SMS service provider for Laravel and Lumen. Uses [SMS Client](https://github.com/matthewbdaly/sms-client) to enable sending SMS messages using the following drivers:
* `nexmo`
* `clockwork`
* `textlocal`
* `twilio`
* `aws` (requires installation of `aws/aws-sdk-php`)
* `mail` (somewhat untested and may be too generic to be much use)Also has the following drivers for testing purposes:
* `log`
* `null`
* `requestbin`Installation for Laravel
------------------------This package is only intended for Laravel 5.5 and up. Install it with the following command:
```bash
$ composer require matthewbdaly/laravel-sms
```Then publish the config file:
```bash
$ php artisan vendor:publish
```You will need to select the service provider `Matthewbdaly\LaravelSMS\LaravelSMSProvider`. Then set your driver and any settings required in the `.env` file for your project:
```
SMS_DRIVER=nexmo
NEXMO_API_KEY=foo
NEXMO_API_SECRET=bar
CLOCKWORK_API_KEY=baz
TEXTLOCAL_API_KEY=baz
REQUESTBIN_PATH=foo
AWS_SNS_API_KEY=foo
AWS_SNS_API_SECRET=bar
AWS_SNS_API_REGION=baz
MAIL_SMS_DOMAIN=my.sms-gateway.com
TWILIO_ACCOUNT_ID=foo
TWILIO_API_TOKEN=bar
```Installation for Lumen
----------------------The installation process with Lumen is identical to that for Laravel, although if you wish to use the facade you will need to uncomment the appropriate section of `bootstrap/app.php` as usual.
Usage
-----Once the package is installed and configured, you can use the facade to send SMS messages:
```php
use SMS;$msg = [
'to' => '+44 01234 567890',
'content' => 'Just testing',
];
SMS::send($msg);
```Or fetch it from the app:
```php
$msg = [
'to' => '+44 01234 567890',
'content' => 'Just testing',
];
$sms = app()['sms']
$sms->send($msg);
```Or resolve the interface `Matthewbdaly\SMS\Contracts\Client`:
```php
$msg = [
'to' => '+44 01234 567890',
'content' => 'Just testing',
];
$sms = app()->make('Matthewbdaly\SMS\Contracts\Client');
$sms->send($msg);
```Here we use the `app()` helper, but you'll normally want to inject it into a constructor or method of another class.