PHPackages                             moocky/aliyunsms - 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. [Mail &amp; Notifications](/categories/mail)
4. /
5. moocky/aliyunsms

ActiveLibrary[Mail &amp; Notifications](/categories/mail)

moocky/aliyunsms
================

基于alibabacloud/dysmsapi-20170525 接入短信服务

v0.1.2(1y ago)029MITPHPPHP &gt;7.2

Since Mar 11Pushed 11mo ago1 watchersCompare

[ Source](https://github.com/moockymark/aliyunsms)[ Packagist](https://packagist.org/packages/moocky/aliyunsms)[ RSS](/packages/moocky-aliyunsms/feed)WikiDiscussions master Synced today

READMEChangelog (2)Dependencies (1)Versions (3)Used By (0)

aliyunsms
=========

[](#aliyunsms)

基于阿里云 SDK alibabacloud/dysmsapi-20170525 接入短信服务

安装
==

[](#安装)

```
composer require moocky/aliyunsms
```

基于laravel框架的使用方法
================

[](#基于laravel框架的使用方法)

加载
--

[](#加载)

在config/app的providers中添加 Moocky\\Aliyunsms\\Providers\\LaravelServiceProvider::class

控制台运行
-----

[](#控制台运行)

```
php artisan vendor:publish --provider=Moocky\Aliyunsms\Providers\LaravelServiceProvider
```

配置
--

[](#配置)

根据新增的aliyunsms.php 文件，在.env文件中添加环境变量：

```
ALIYUN_ACCESS_KEY_ID=your access key
ALIYUN_ACCESS_KEY_SECRET=your access secret
ALIYUN_DYSMS_ENDPOINT=endpoint         # 短信发送节点，没有配置时为dysmsapi.aliyuncs.com
ALIYUN_DYSMS_SIGN_NAME=your sign name  # 短信签名，必须配置
ALIYUN_DYSMS_VERIFICATION_TEMPLATE=verification template code # 验证码模板代码，不发送验证可不配置
ALIYUN_DYSMS_SMS_LOG_TABLE=sms_log     # 短信日志表名称
```

创建短信日志表
-------

[](#创建短信日志表)

```
php artisan aliyunsms:table
php artisan migrate:install # 或 php artisan migrate
```

使用
--

[](#使用)

```
namespace App\Http\Controllers;

use Moocky\Aliyunsms\Contracts\Aliyunsms;
....

class IndexController extends Controller
{
  /**
   * Show the application dashboard.
   *
   * @param \Moocky\Aliyunsms\Contracts\Aliyunsms $aliyunsms 注入
   */
  public function index(Aliyunsms $aliyunsms)
  {
    # 发送普通短信
    #
    # $phone 手机号
    # $templateCode 短信模板
    # $templateParam 短信参数
    # $type 短信类型，默认为normal

    $aliyunsms->send('13888888888','SMS_112233445566',['rand' => 123456],'normal');
    $aliyunsms->send('13888888888','SMS_556677889900');
  }
  public function send()
  {
    # 发送普通短信
    #
    # $phone 手机号
    # $templateCode 短信模板
    # $templateParam 短信参数
    # $type 短信类型，默认为normal

    app('aliyunsms')->send('13888888888','SMS_112233445566',['rand' => 123456],'normal');
    app('aliyunsms')->send('13888888888','SMS_556677889900');
  }
  public function verification()
  {
    # 发送验证码
    #
    # $phone 手机号
    # $type 验证码类型，默认为verification
    app('aliyunsms')->verification('13888888888','verification');
    app('aliyunsms')->verification('13888888888');
  }
  public function verify()
  {
    # 校验验证码
    #
    # $phone 手机号
    # $rand 验证码
    # $type 验证码类型，默认为verification
    # $expires 验证码有效时间，默认为600秒
    app('aliyunsms')->verify('13888888888','123456','verification',1200);
    app('aliyunsms')->verify('13888888888','123456');
  }
}
```

非laravel框架的使用方法
===============

[](#非laravel框架的使用方法)

```
use Moocky\Aliyunsms\Aliyunsms;

$config = [
	'access_key_id' => 'your access key',
	'access_key_secret' => 'your access secret',
	'sign_name' => 'your sign name',
	'endpoint' => 'endpoint',
	'template_code' => 'SMS_112233445566',
	'sms_log_table' => 'sms_log',
];

# 发送普通短信
#
# $phone 手机号
# $templateCode 短信模板
# $templateParam 短信参数
# $type 短信类型，默认为normal
$aliyunsms = new Aliyunsms($config);
$aliyunsms->send('13888888888','SMS_112233445566',['rand' => 123456],'normal');
$aliyunsms->send('13888888888','SMS_556677889900');

# 发送验证码
#
# $phone 手机号
# $type 验证码类型，默认为verification
$aliyunsms = new Aliyunsms($config);
$aliyunsms->verification('13888888888','verification');
$aliyunsms->verification('13888888888');

# 校验验证码
#
# $phone 手机号
# $rand 验证码
# $type 验证码类型，默认为verification
# $expires 验证码有效时间，默认为600秒
$aliyunsms = new Aliyunsms($config);
$aliyunsms->verify('13888888888','123456','verification',1200);
$aliyunsms->verify('13888888888','123456');
```

###  Health Score

22

—

LowBetter than 21% of packages

Maintenance47

Moderate activity, may be stable

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity24

Early-stage or recently created project

 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 ~0 days

Total

2

Last Release

479d ago

### Community

Maintainers

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

---

Top Contributors

[![moockymark](https://avatars.githubusercontent.com/u/43465076?v=4)](https://github.com/moockymark "moockymark (33 commits)")

---

Tags

phplaravellumensmsalibabaclouddysmsapiAliyunSMS

### Embed Badge

![Health badge](/badges/moocky-aliyunsms/health.svg)

```
[![Health](https://phpackages.com/badges/moocky-aliyunsms/health.svg)](https://phpackages.com/packages/moocky-aliyunsms)
```

###  Alternatives

[ferdous/laravel-otp-validate

Laravel package for OTP validation with built-in features like retry and resend mechanism. Built in max retry and max resend blocking. OTP/Security Code can be send over SMS or Email of your choice with user-defined template.

7124.6k](/packages/ferdous-laravel-otp-validate)[matthewbdaly/laravel-sms

A Laravel and Lumen integration for matthewbdaly/sms-client to enable sending SMS messages

3529.8k](/packages/matthewbdaly-laravel-sms)[djunehor/laravel-sms

Send SMS from your laravel application

395.7k1](/packages/djunehor-laravel-sms)

PHPackages © 2026

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