livaco/easydiscordwebhook
Composer 安装命令:
composer require livaco/easydiscordwebhook
包简介
An simple, lightweight, easy to use library to allow you to create and send discord webhooks in PHP.
README 文档
README
EasyDiscordWebhook is a simple, easy to use library to allow you to create and send discord webhooks in PHP with minimal effort.
Installation
EasyDiscordWebhook can be installed just like any other composer package.
composer require livaco\easydiscordwebhook
Usage
To get started, we'll start by making a DiscordWebhook object. This is done as such.
$webhook = DiscordWebhook::new("https://discord.com/api/webhooks/your/webhook");
The argument in the new function is for your webhook url.
Next, we can begin setting what our webhook should contain. Every webhook requires either text in the content, or at least one embed.
We'll keep it simple for now though, and just have it say o'l "Hello, world!". EasyDiscordWebhook supports fluent interface, so we'll use that as well and get rid of the $webhook variable.
To set the content of the webhook, we'll use the setContent function. To send it, you from here just need to call the execute function.
DiscordWebhook::new("https://discord.com/api/webhooks/your/webhook") ->setContent("Hello, world!") ->execute();
Cool, right? Let's add an embed now. Let's pretend it's a game information webhook, and we want some basic information about Cyberpunk 2077 (I suck at examples, so this is the best I got).
Embeds are added using the addEmbed function. From there, we can feed it an embed object that has all the information attached to it. Once again, we create this object using Embed::new() and from there we can use the functions provided to fill out the data.
DiscordWebhook::new("https://discord.com/api/webhooks/your/webhook") ->addEmbed(Embed::new() ->setTitle("Cyberpunk 2077") ->setDescription("Cyberpunk 2077 is an open-world, action-adventure RPG set in the megalopolis of Night City, where you play as a cyberpunk mercenary wrapped up in a do-or-die fight for survival. Improved and featuring all-new free additional content, customize your character and playstyle as you take on jobs, build a reputation, and unlock upgrades. The relationships you forge and the choices you make will shape the story and the world around you. Legends are made here. What will yours be?") ->addField("Release Date", "December 10, 2020", true) ->addField("Platforms", "All Major Platforms", true) ->addField("Developer", "CD Projekt Red", true) ->setColor("#FCFF2B") ->setUrl("https://www.cyberpunk.net/gb/en/") ->setImage("https://upload.livaco.dev/u/nYLGepk6X2.png") ) ->execute();
If you want more examples, take a look in /examples.
livaco/easydiscordwebhook 适用场景与选型建议
livaco/easydiscordwebhook 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 146 次下载、GitHub Stars 达 7, 最近一次更新时间为 2019 年 10 月 16 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「webhook」 「discord」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 livaco/easydiscordwebhook 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 livaco/easydiscordwebhook 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 livaco/easydiscordwebhook 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A simple monolog handler for support Discord webhooks
Send Notification to discord channel Webhook using native FilamentPHP Notification Facade class
Inbox pattern process implementation for your Laravel Applications
A simple package to create tables in Discord messages.
GitHub Webhook Listener with plugin-based API for creating your own triggerered actions
统计信息
- 总下载量: 146
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 7
- 点击次数: 19
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Apache-2.0
- 更新时间: 2019-10-16