PHPackages                             timeshow/laravel-sms - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. timeshow/laravel-sms

ActiveLibrary[API Development](/categories/api)

timeshow/laravel-sms
====================

Sms Api for Laravel

v0.5.0(2y ago)045MITPHPPHP ^8.1

Since Jun 6Pushed 2y ago1 watchersCompare

[ Source](https://github.com/timeshow/laravel-sms)[ Packagist](https://packagist.org/packages/timeshow/laravel-sms)[ RSS](/packages/timeshow-laravel-sms/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (3)Versions (16)Used By (0)

Laravel SMS
-----------

[](#laravel-sms)

This is a Laravel Package for SMS Gateway Integration. Now Sending SMS is easy.

List of supported gateways:

- [Juhe](https://www.juhe.cn/)
- [Aliyun](https://www.aliyun.com/product/sms)
- [YunPian](https://www.yunpian.com/)
- [QQPian](https://cloud.tencent.com/product/sms)

Install
-------

[](#install)

Via Composer

```
$ composer require timeshow/laravel-sms
```

add the `SmsServiceProvider` to your `config/app.php`:

```
//providers
'providers' => [
    // ...
    TimeShow\Sms\SmsServiceProvider::class,
]

//aliases
'aliases' => [
    //...
    'Sms' => TimeShow\Sms\Facades\Sms::class,
]
```

Publish the sms configuration file.

```
php artisan vendor:publish --tag="sms"
```

In the config file you can set the default driver to use for all your SMS. But you can also change the driver at runtime.

Choose what gateway you would like to use for your application. Then make that as default driver so that you don't have to specify that everywhere. But, you can also use multiple gateways in a project.

Configure(.env)

```
//default driver
SMS_DEFAULT=aliyun

//fallback driver
SMS_FALLBACK=juhe

//default signName  (Important: The signName should be enclosed in {})
SMS_SIGNNAME={sms}

ALIYUN_APP_KEY=your-appkey
ALIYUN_APP_SECRET=your-appsecret
ALIYUN_TEMPLATE_ID=your-templates-id  //Value：SMS_12345678

JUHE_KEY=your-key
JUHE_TEMPLATE_ID=your-templates-id  //Value：123456

YUNPIAN_API_KEY=your-appkey
YUNPIAN_TEMPLATE_CONTENT=your-template-content  //Value：您的验证码是{verifyCode}，有效期为{time}分钟，请尽快验证

QQYUN_APP_ID=your-appid
QQYUN_APP_KEY=your-appkey
QQYUN_TEMPLATE_ID=your-templates-id //Value：12345
```

Then fill the credentials for that gateway in the drivers array.

```
/*
|--------------------------------------------------------------------------
| Default Driver
|--------------------------------------------------------------------------
*/
'default' => env('SMS_DRIVER', 'aliyun'),
'fallback' => env('SMS_FALLBACK', 'juhe'),
'signName' => env('SMS_SIGNNAME', ''),

/*
|--------------------------------------------------------------------------
| List of Drivers
|--------------------------------------------------------------------------
*/
'drivers' => [
    // Install: composer require
    'aliyun' => [
        'appKey' => env('ALIYUN_APP_KEY', 'Your Access Key'),
        'appSecret' => env('ALIYUN_APP_SECRET', 'Your Secret Key'),
        'templateId' => env('ALIYUN_TEMPLATE_ID', 0),
        'driverFile' => 'ALiYun',
    ],
    'juhe' => [
        'key' => env('JUHE_KEY', 'Your Access Key'),
        'templateId' => env('JUHE_TEMPLATE_ID', 0),
        'driverFile' => 'JuHe',
    ],
    'yunpian' => [
        'apiKey' => env('YUNPIAN_API_KEY'),
        'templateContent' => env('YUNPIAN_TEMPLATE_CONTENT'),
        'driverFile' => 'YunPian',
    ],
    'qqyun' => [
        'appId' => env('QQYUN_APP_ID', 'Your App Id'),
        'appKey' => env('QQYUN_APP_KEY', 'Your App Key'),
        'templateId' => env('QQYUN_TEMPLATE_ID', 0),
        'executableFile' => 'QQYun',
    ],
],
```

Basic Usage
-----------

[](#basic-usage)

use it like this

```
//default
$sms = Sms::driver();
//fallback
$sms = Sms::driver('fallback');
//other options
$sms = Sms::driver('juhe');
$sms = Sms::driver('aliyun');
$sms = Sms::driver('yunpian');
```

Usage
-----

[](#usage)

```
$sms = Sms::driver();
$sms->setTemplateId(123456);
$sms->setSignName('your_signName');
$sms->setContent($content);
$sms->setContentByVerifyCode(20);  //Your verification code is {verifyCode}, valid for 20 minutes
$sms->makeStr();   // Generate a 16 bit default random string
$sms->makeCode(6);   // 100000~999999  1000~9999  10000000~99999999
$sms->makeRandom();  // 100000~999999

$templateVar = ['code' => $verifyCode];   // ['code' => '110101', 'time' =>'10']
$sms->setTemplateVar($templateVar);
$sms->setTemplateVar($templateVar, true);

$sms->send($mobile);
$sms->send($mobile, false);
```

Basic Usage
-----------

[](#basic-usage-1)

```
// JuHe
$sms->setContent('#code#=' . $code);

// ALiYun & QQYun
$templateVar = ['code' => $code];

// YunPian
$sms->setContentByVerifyCode();
```

Example
-------

[](#example)

```
// Custom
$sms = Sms::driver();
$default = config('sms.default');
$templateId = config('sms.drivers.' . $default . '.templateId');
$sms->setTemplateId($templateId);
$content = 'Your verification code is {verifyCode}, Valid for {time} minutes';
$sms->setContent($content);
$result = $sms->send($mobile);

//Or JuHe
$sms = Sms::driver();
$default = config('sms.default');
$templateId = config('sms.drivers.' . $default . '.templateId');
$sms->setTemplateId($templateId);
$code = $sms->makeCode(6);
$sms->setContent('#code#='.$code);
$result = $sms->send($mobile, true);

//Or ALiYun
$sms = Sms::driver();
$default = config('sms.default');
$templateId = config('sms.drivers.' . $default . '.templateId');
$sms->setTemplateId($templateId);
$code = $sms->makeCode(6);
$templateVar = ['code' => $code];
$sms->setTemplateVar($templateVar, true);
$result = $sms->send($mobile, true);

//Or YunPian
$sms = Sms::driver();
$templateVar = ['yzm' => 'verifyCode'];
$sms->setTemplateVar($templateVar, true);
$sms->setContentByVerifyCode(20);
$result = $sms->send($mobile);

//Or Set Content By Custom
$sms = Sms::driver();
$sms->setSignName('your_signName');
$content = '{name},Your account is logged in from another location. If it was not for you, please change the password in a timely manner';  //content
$templateVar = ['name' => 'you name'];
$sms->setContent($content);
$sms->setContentByCustomVar($templateVar);
//Value：you name,Your account is logged in from another location. If it was not for you, please change the password in a timely manner

//Or QQYun
$sms = Sms::driver();
$default = config('sms.default');
$templateId = config('sms.drivers.' . $default . '.templateId');
$sms->setTemplateId($templateId);
$code = $sms->makeCode(6);
$templateVar = ['code' => $code];
$sms->setTemplateVar($templateVar, true);
$result = $sms->send($mobile, true);
```

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

License
-------

[](#license)

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

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~18 days

Recently: every ~38 days

Total

15

Last Release

811d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/57834562?v=4)[timeshow](/maintainers/timeshow)[@timeshow](https://github.com/timeshow)

---

Top Contributors

[![timeshow](https://avatars.githubusercontent.com/u/57834562?v=4)](https://github.com/timeshow "timeshow (19 commits)")

---

Tags

laravelsmslaravel-smsphp-sms

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/timeshow-laravel-sms/health.svg)

```
[![Health](https://phpackages.com/badges/timeshow-laravel-sms/health.svg)](https://phpackages.com/packages/timeshow-laravel-sms)
```

###  Alternatives

[tzsk/sms

A robust and unified SMS gateway integration package for Laravel, supporting multiple providers.

320244.3k6](/packages/tzsk-sms)[essa/api-tool-kit

set of tools to build an api with laravel

52680.5k](/packages/essa-api-tool-kit)[resend/resend-laravel

Resend for Laravel

1191.4M6](/packages/resend-resend-laravel)[joggapp/laravel-aws-sns

Laravel package for the SNS events by AWS

3171.8k](/packages/joggapp-laravel-aws-sns)[simplestats-io/laravel-client

Client for SimpleStats!

4515.5k](/packages/simplestats-io-laravel-client)[ardakilic/mutlucell

Mutlucell SMS API wrapper for sending sms text messages for Laravel

457.3k](/packages/ardakilic-mutlucell)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
