Download the PHP package joelhinz/laravel-quick-slack without Composer
On this page you can find all versions of the php package joelhinz/laravel-quick-slack. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download joelhinz/laravel-quick-slack
More information about joelhinz/laravel-quick-slack
Files in joelhinz/laravel-quick-slack
Package laravel-quick-slack
Short Description An easy way of quickly sending messages to predefined Slack endpoints within a Laravel project.
License MIT
Informations about the package laravel-quick-slack
Laravel QuickSlack
A simple package to quickly send messages to Slack channels through Laravel. Tested with Laravel 5.4 through 8.
Installation
Use Composer to install the package:
This package supports auto-discovery, so if you're using Laravel 5.5, you're all set.
For Laravel 5.4, or if you don't want to use auto-discovery, add the provider and optionally the facade alias to your config/app.php
file:
Basic usage
Before sending messages, all you need to do is go to Slack and create an incoming webhook, then copy the webhook url.
The webhook url can be remembered for subsequent calls during the same script execution by passing a boolean as the second argument to the to()
method:
Since QuickSlack is fluent, you can just keep chaining more messages if you want to. Please note that this requires a remembered webhook url, or a default webhook (see configuration options below).
Don't like how long the webhook urls get? No worries, you can just skip the first part of them. Instead of https://hooks.slack.com/services/[rest of url]
, just enter everything after services/
instead. QuickSlack will handle the rest automatically.
Configuration
QuickSlack can be used without any configuration, but you can export the configuration to get features such as a default webhook and named webhooks.
This will create a file config/quick-slack.php
where you can set your configuration options as follows:
Again, you can enter either full urls or just the webhook-specific part of them.
By using named webhooks, you don't have to remember their full addresses when you send messages:
If you only or mainly send to just one endpoint, you can put that as the default and omit the to()
method. The default value can be overwritten by using the to()
method, and the overwriting url can be remembered as per above.
Webhook names are recursive, so that you can use different names for the same endpoint:
They are also nestable if you prefer to organise things that way:
Webhook precedence
When sending a message, QuickSlack will determine which endpoint to use in the following order of precedence:
- The webhook given in the last
to()
call if no message has been sent since then. - The webhook given in the last
to()
call if the remember option is set to true. - The default webhook in the configuration file.
TODO
Planned functionality includes
- Automated tests and Travis integration
- Style CI integration
- Support for custom emojis and usernames
- Support for changing channel ad-hoc
- Support for saved teams in the configuration
- Support for additional styling as per Slack's payload documentation
- Custom response and exception handling
- Global helper
quickslack($message[, $endpoint])
License
Standard MIT License (MIT), available in LICENSE.