huangdijia/laravel-sms

laravel 的短信功能

1.1.7 2020-11-24 10:13 UTC

This package is auto-updated.

Last update: 2024-09-24 18:01:38 UTC


README

Latest Stable Version Total Downloads GitHub license

安装

安装包

composer require huangdijia/laravel-sms

配置安装

php artisan sms:install

使用

发送短信简单易用

use Huangdijia\Sms\Facades\Sms;

Sms::to('phone number')->content('message content')->send();

检查发送结果

$response = Sms::to('phone number')->content('message content')->send();

if ($response->successful()) {
    // success
}

抛出异常

$response = Sms::to('phone number')->content('message content')->send();

$response->throw();

切换短信工厂

Sms::use('another')->to('phone number')->content('message content')->send();

使用验证规则

Sms::withRules([
    'to'      => 'required|numeric|....',
    'content' => 'required|...',
], [
    'to.required'      => ':attribute cannot be empty!',
    'content.required' => ':attribute cannot be empty!',
    // more messages
])->to()->content()->send();