Download the PHP package slack-php/slick without Composer
On this page you can find all versions of the php package slack-php/slick. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download slack-php/slick
More information about slack-php/slick
Files in slack-php/slick
Package slick
Short Description Simple micro-framework for Slack app development
License MIT
Informations about the package slick
Slick (by slack-php)
A slick, single-file, dependency-free PHP micro-framework for building simple Slack apps.
For something more robust, you should use our fully-featured Slack PHP Framework.
If you are new to Slack app development, you will want to learn about it on Slack's website.
Installation
Requirements
Requires PHP 7.3+ with JSON support.
Via Composer
We recommend using Composer to install Slick, so that autoloading and keeping it up-to-date are easy.
Manual
However, since Slick has no dependencies, you can directly download and require Slick.php
or copy & paste the code
directly into your project.
(If you do end up doing this, let me know, because I will have no other way to track that it's happening.)
Basic Usage
This small app responds to the /cool
slash command by posting a message back to the conversation where
the slack command was used.
Assumptions:
- You have required the Composer autoloader to autoload Slick, OR you have required
Slick.php
directly.- You have
SLACK_SIGNING_KEY
set in your environment such that it is present in$_SERVER
.
Want to run this example in your workspace? Check out the Example App using Docker.
Breaking It Down
Let's add some comments to that last example, so you know what is going on.
Customization
There isn't much to customize, but you can control the behavior of your Slick Slack app when:
- The incoming request doesn't match one of your routes (
on404()
). - An error occurs while processing the incoming request (
orErr()
).
Helper Functions
If you want to do your own request handling, Slick provides some static helper methods that you can use independent from the routing features.
Slick::validateSignature(string $key, string $signature, int $time, string $body): void
– Validates a Slack request signature using their v0 algorithm.Slick::parseRequestBody(string $body): array
– Parses a request body into an associative array of Slack payload data. Works for any payload type. Must provide the raw request body as a string (e.g., fromphp://input
).Slick::getPayloadType(array $payload): string
– Determines the payload type from an array of payload data.Slick::getPayloadId(array $payload): string
– Determines the payloads routable ID from an array of payload data, based on its type.Slack::ack(string $ack): void
– Echos an "ack" response with suitable headers and status code.