Search by

hughcube / laravel-dingtalk

hughcube

Package info

github.com/hughcube/laravel-dingtalk

pkg:composer/hughcube/laravel-dingtalk

Statistics

Installs: 7 959

Dependents: 1

Suggesters: 0

Stars: 0

Open Issues: 0

v1.2.0 2026-10-27 10:32 UTC

This package is auto-updated.

Last update: 2026-10-27 10:33:54 UTC


README

Test Actions status Lint Actions status StyleCI Code Coverage Scrutinizer Code Quality Code Intelligence Status PHP Versions Supported Latest Stable Version Total Downloads License Latest Unstable Version composer.lock available

Installing

$ composer require hughcube/laravel-dingtalk -vvv

Configuration

[
    /**
     * default config
     */
    'defaults' => [],

    'robots' => [
        'default' => [
            'enabled' => env('DING_TALK_ROBOT_ENABLED', true),

            /**
             * The full webhook url, e.g. https://oapi.dingtalk.com/robot/send?access_token=xxx
             */
            'url' => env('DING_TALK_ROBOT_URL', ''),

            /**
             * The robot access_token, the default url will be generated automatically
             */
            'access_token' => env('DING_TALK_ROBOT_ACCESS_TOKEN', ''),

            /**
             * The robot secret, timestamp and sign will be appended automatically
             */
            'secret' => env('DING_TALK_ROBOT_SECRET', ''),
        ]
    ]
]

Configure either url or access_token, they are interchangeable:

# option 1: the full webhook url
DING_TALK_ROBOT_URL=https://oapi.dingtalk.com/robot/send?access_token=xxxxxxxx

# option 2: only the access_token
DING_TALK_ROBOT_ACCESS_TOKEN=xxxxxxxx

When both are configured the url wins. If the robot has a secret (DING_TALK_ROBOT_SECRET=SECxxxxxxxx), timestamp and sign are appended to the url automatically in both modes.

Usage

use HughCube\Laravel\DingTalk\DingTalk;
use HughCube\Laravel\DingTalk\Robot\Messages\Text;

DingTalk::robot()->send(new Text('hello world'));

// multi robot
DingTalk::robot('other')->send(new Text('hello world'));

Log channel

'channels' => [
    'dingtalk' => [
        'driver'  => 'monolog',
        'handler' => HughCube\Laravel\DingTalk\Log\Handler::class,
        'with'    => [
            'robot'   => null, // the robot name, null means "default"
            'enabled' => env('DING_TALK_ROBOT_ENABLED', true),
            'level'   => 'warning',
        ],
    ],
],

Test

$ composer test

# integration test against a real robot (optional)
$ DING_TALK_ROBOT_URL='https://oapi.dingtalk.com/robot/send?access_token=xxx' DING_TALK_ROBOT_SECRET='SECxxx' ./vendor/bin/phpunit

Contributing

You can contribute in one of three ways:

  1. File bug reports using the issue tracker.
  2. Answer questions or fix bugs on the issue tracker.
  3. Contribute new features or update the wiki.

The code contribution process is not very formal. You just need to make sure that you follow the PSR-0, PSR-1, and PSR-2 coding guidelines. Any new code contributions must be accompanied by unit tests where applicable.

License

MIT