spatie/laravel-slack-slash-command
Composer 安装命令:
composer require spatie/laravel-slack-slash-command
包简介
Make a Laravel app respond to a slash command from Slack
关键字:
README 文档
README
Making a Laravel app respond to Slack commands
This package makes it easy to make your Laravel app respond to Slack's Slash commands.
Once you've setup your Slash command over at Slack and installed this package into a Laravel app you can create handlers that can handle a slash command. Here's an example of such a handler that will send a response back to slack.
namespace App\SlashCommandHandlers; use App\SlashCommand\BaseHandler; use Spatie\SlashCommand\Request; use Spatie\SlashCommand\Response; class CatchAll extends BaseHandler { /** * If this function returns true, the handle method will get called. * * @param \Spatie\SlashCommand\Request $request * * @return bool */ public function canHandle(Request $request): bool { return true; } /** * Handle the given request. Remember that Slack expects a response * within three seconds after the slash command was issued. If * there is more time needed, dispatch a job. * * @param \Spatie\SlashCommand\Request $request * * @return \Spatie\SlashCommand\Response */ public function handle(Request $request): Response { return $this->respondToSlack("You have typed this text: `{$request->text}`"); } }
Spatie is a webdesign agency based in Antwerp, Belgium. You'll find an overview of all our open source projects on our website.
Support us
We invest a lot of resources into creating best in class open source packages. You can support us by buying one of our paid products.
We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on our contact page. We publish all received postcards on our virtual postcard wall.
Installation
You can install the package via composer:
composer require spatie/laravel-slack-slash-command
This service provider must be installed.
// config/app.php 'providers' => [ ... Spatie\SlashCommand\SlashCommandServiceProvider::class, ];
You can publish the config-file with:
php artisan vendor:publish --provider="Spatie\SlashCommand\SlashCommandServiceProvider"
This is the contents of the published file:
return [ /* * At the integration settings over at Slack you can configure the url to which the * slack commands are posted. Specify the path component of that url here. * * For `http://example.com/slack` you would put `slack` here. */ 'url' => 'slack', /* * The token generated by Slack with which to verify if a incoming slash command request is valid. */ 'token' => env('SLACK_SLASH_COMMAND_VERIFICATION_TOKEN'), /* * The signing_secret generated by Slack with which to verify if a incoming slash command request is valid. */ 'signing_secret' => env('SLACK_SIGNING_SECRET'), /* * Verify requests from slack with signing_secret signature */ 'verify_with_signing' => false, /* * The handlers that will process the slash command. We'll call handlers from top to bottom * until the first one whose `canHandle` method returns true. */ 'handlers' => [ //add your own handlers here //this handler will display instructions on how to use the various commands. Spatie\SlashCommand\Handlers\Help::class, //this handler will respond with a `Could not handle command` message. Spatie\SlashCommand\Handlers\CatchAll::class, ], ];
Change verify_with_signing parameter to verify requests from slack by signing_secret:
// config/laravel-slack-slash-command.php 'verify_with_signing' => true
Documentation
You'll find the documentation on https://docs.spatie.be/laravel-slack-slash-command.
Find yourself stuck using the package? Found a bug? Do you have general questions or suggestions for improving the media library? Feel free to create an issue on GitHub, we'll try to address it as soon as possible.
Changelog
Please see CHANGELOG for more information what has changed recently.
Testing
$ composer test
Contributing
Please see CONTRIBUTING for details.
Security
If you've found a bug regarding security please mail security@spatie.be instead of using the issue tracker.
Postcardware
You're free to use this package, but if it makes it to your production environment we highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using.
Our address is: Spatie, Kruikstraat 22, 2018 Antwerp, Belgium.
We publish all received postcards on our company website.
Credits
The message and attachment functionalities were heavily inspired on Regan McEntyre's Slack package.
License
The MIT License (MIT). Please see License File for more information.
spatie/laravel-slack-slash-command 适用场景与选型建议
spatie/laravel-slack-slash-command 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 678.44k 次下载、GitHub Stars 达 254, 最近一次更新时间为 2016 年 07 月 09 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「spatie」 「laravel-slack」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 spatie/laravel-slack-slash-command 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 spatie/laravel-slack-slash-command 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 spatie/laravel-slack-slash-command 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Laravel log Alarm help you to set up alarm when errors occur in your system and send you a notification via Slack and email
Receive webhooks in Laravel apps
Easily optimize images using PHP
Store your application settings
Add tags and taggable behaviour to your Laravel app
Speed up a Laravel application by caching the entire response additions
统计信息
- 总下载量: 678.44k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 255
- 点击次数: 26
- 依赖项目数: 2
- 推荐数: 1
其他信息
- 授权协议: MIT
- 更新时间: 2016-07-09