hughcube / laravel-dingtalk
v1.2.0
2026-10-27 10:32 UTC
Requires
- php: 8.*
- ext-mbstring: *
- guzzlehttp/guzzle: *
- hughcube/laravel-service-support: ^1.0
- monolog/monolog: *
Requires (Dev)
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
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:
- File bug reports using the issue tracker.
- Answer questions or fix bugs on the issue tracker.
- 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