PHPackages                             jacksmall/dd-notification-channel - 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. jacksmall/dd-notification-channel

ActiveLibrary

jacksmall/dd-notification-channel
=================================

DingDing Notification Channel for laravel.

1.1.2(11mo ago)118MITPHPPHP ^7.1.3|^8.0

Since May 28Pushed 11mo ago1 watchersCompare

[ Source](https://github.com/Jacksmall/dd-notification-channel)[ Packagist](https://packagist.org/packages/jacksmall/dd-notification-channel)[ RSS](/packages/jacksmall-dd-notification-channel/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (2)Versions (2)Used By (0)

Laravel DingTalk Notification Channel
=====================================

[](#laravel-dingtalk-notification-channel)

---

### 1.通过composer安装:

[](#1通过composer安装)

```
```
composer require jacksmall/dd-notification-channel
```

```

### 2.在本地laravel项目中新建 config\\dingding.php

[](#2在本地laravel项目中新建-configdingdingphp)

```
return [
    'robots' => [
        'default' => [
            'webhook_url' => env('DINGDING_DEFAULT_WEBHOOK_URL'),
            'secret' => env('DINGDING_DEFAULT_SECRET'),
        ],
        'marketing' => [
            'webhook_url' => env('DINGDING_MARKETING_WEBHOOK_URL', ''),
            'secret' => env('DINGDING_MARKETING_SECRET', ''),
        ],
        'finance' => [
            'webhook_url' => env('DINGDING_FINANCE_WEBHOOK_URL', ''),
            'secret' => env('DINGDING_FINANCE_SECRET', ''),
        ],
        'ops' => [
            'webhook_url' => env('DINGDING_OPS_WEBHOOK_URL', ''),
            'secret' => env('DINGDING_OPS_SECRET', ''),
        ],
    ]
];
```

### 3.在 .env 文件按需添加, access\_token和secret自行提供

[](#3在-env-文件按需添加-access_token和secret自行提供)

```
DINGDING_DEFAULT_WEBHOOK_URL=https://oapi.dingtalk.com/robot/send?access_token=xxx
DINGDING_DEFAULT_SECRET=xxxx

```

### 4.在本地laravel项目中新建

[](#4在本地laravel项目中新建)

App\\Services\\DingDing\\Config.php

```
namespace App\Services\DingDing;

class Config
{
    protected $robots = [];

    public function __construct()
    {
        $this->robots = config('dingding.robots', []);
    }

    public function getRobotConfig(string $name = 'default')
    {
        return $this->robots[$name] ?? null;
    }

    public function getWebhookUrl(string $name = 'default'): string
    {
        return $this->getRobotConfig($name)['webhook_url'] ?? '';
    }

    public function getSecret(string $name = 'default'): string
    {
        return $this->getRobotConfig($name)['secret'] ?? '';
    }
}
```

App\\Services\\DingDing\\Signer.php

```
namespace App\Services\DingDing;

class Signer
{
    public function generate(string $secret): array
    {
        $timestamp = time() * 1000;
        $sign = base64_encode(hash_hmac('sha256', $timestamp . "\n" . $secret, $secret, true));
        return [urlencode($sign), $timestamp];
    }
}
```

App\\Services\\DingDingService.php

```
namespace App\Services;

use App\Services\DingDing\Config;
use App\Services\DingDing\Signer;
use Illuminate\Notifications\Notification;
use Illuminate\Support\Facades\Notification as NotificationFacade;

class DingDingService
{
    protected $signer;
    protected $config;

    public function __construct(Config $config, Signer $signer)
    {
        $this->signer = $signer;
        $this->config = $config;
    }

    /**
     * @param string $robotName
     * @return string
     */
    public function getSignedUrl(string $robotName = 'default')
    {
        $url = $this->config->getWebhookUrl($robotName);
        $secret = $this->config->getSecret($robotName);

        if (empty($url) || empty($secret)) {
            throw new \InvalidArgumentException("Invalid DingDing config for: {$robotName}");
        }

        [$sign, $timestamp] = $this->signer->generate($secret);

        return "{$url}&timestamp={$timestamp}&sign={$sign}";
    }

    /**
     * @param Notification $notification
     * @param string $robotName
     * @return void
     */
    public function sendNotification(Notification $notification, string $robotName = 'default')
    {
        $url = $this->getSignedUrl($robotName);

        NotificationFacade::route('dingding', $url)->notify($notification);
    }
}
```

### 5.在本地laravel项目App\\Providers\\AppServiceProvider.php 中注册绑定服务:

[](#5在本地laravel项目appprovidersappserviceproviderphp-中注册绑定服务)

```
use App\Services\DingDing\Config;
use App\Services\DingDing\Signer;
use App\Services\DingDingService;
...
        $this->app->singleton(Config::class, function () {
            return new Config();
        });

        $this->app->singleton(Signer::class, function () {
            return new Signer();
        });

        $this->app->singleton(DingDingService::class, function($app) {
            return new DingDingService(
                $app->make(Config::class),
                $app->make(Signer::class)
            );
        });
...
```

### 6.在本地laravel项目按需建立notice类，测试如下

[](#6在本地laravel项目按需建立notice类测试如下)

```
php artisan make:notification TestDingDingNotice

```

App\\Notifications\\TestDingDingNotice.php

```
namespace App\Notifications;

use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Jacksmall\DdNotificationChannel\Channels\DingDingChannel;

class TestDingDingNotice extends Notification
{
    use Queueable;

    public $message;

    /**
     * Create a new notification instance.
     *
     * @return void
     */
    public function __construct($message)
    {
        $this->message = $message;
    }

    /**
     * Get the notification's delivery channels.
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function via($notifiable)
    {
        return [DingDingChannel::class];
    }

    /**
     * Get the dingding representation of the notification.
     *
     * @param  mixed  $notifiable
     */
    public function toDingDing($notifiable)
    {
        return [
            'type' => 'text',
            'params' => [
                'content' => $this->message
            ],
            'http' => [
                'verify' => false,
                'timeout' => 5
            ] // 可选 HTTP 参数
        ];
    }
}
```

### 7.调用如下

[](#7调用如下)

```
    /**
     * @return void
     */
    public function dingTalkNotification(Request $request)
    {
        $notification = new TestDingDingNotice($request->input('message'));

        app(DingDingService::class)->sendNotification($notification, 'default');
    }
```

☺ ☺
===

[](#-)

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance54

Moderate activity, may be stable

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

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

Unknown

Total

1

Last Release

346d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/d55bc2e7f2866b5c6ae1f5a70e6f25711c82c518db48553c2f1bbf49c4332ab9?d=identicon)[Jacksmall](/maintainers/Jacksmall)

---

Top Contributors

[![Jacksmall](https://avatars.githubusercontent.com/u/12547809?v=4)](https://github.com/Jacksmall "Jacksmall (16 commits)")

---

Tags

dingtalk-robotlaravelnotification-channellaravelnotificationsdingtalkdingding

### Embed Badge

![Health badge](/badges/jacksmall-dd-notification-channel/health.svg)

```
[![Health](https://phpackages.com/badges/jacksmall-dd-notification-channel/health.svg)](https://phpackages.com/packages/jacksmall-dd-notification-channel)
```

###  Alternatives

[laravel/slack-notification-channel

Slack Notification Channel for laravel.

89069.7M111](/packages/laravel-slack-notification-channel)[spatie/laravel-health

Monitor the health of a Laravel application

85810.0M83](/packages/spatie-laravel-health)[s-ichikawa/laravel-sendgrid-driver

This library adds a 'sendgrid' mail driver to Laravel.

4139.3M1](/packages/s-ichikawa-laravel-sendgrid-driver)[laravel-notification-channels/discord

Laravel notification driver for Discord.

2371.3M11](/packages/laravel-notification-channels-discord)[benwilkins/laravel-fcm-notification

Laravel FCM (Firebase Cloud Messaging) Notification Channel

210964.1k1](/packages/benwilkins-laravel-fcm-notification)[calchen/laravel-dingtalk-robot-notification

钉钉智能群助手 Laravel/Lumen 消息通知扩展包（Dingtalk robot message notifications for Laravel/Lumen）

2326.4k](/packages/calchen-laravel-dingtalk-robot-notification)

PHPackages © 2026

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