{"id":19456394,"url":"https://github.com/slack-php/slack-php-slick","last_synced_at":"2025-04-25T05:31:00.184Z","repository":{"id":57053041,"uuid":"375533795","full_name":"slack-php/slack-php-slick","owner":"slack-php","description":"Dependency-free micro-framework for building Slack apps in PHP","archived":false,"fork":false,"pushed_at":"2021-06-11T20:10:43.000Z","size":26,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-04-13T17:04:52.780Z","etag":null,"topics":["blockkit","framework","micro-framework","php","slack","slack-api","slack-bot"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/slack-php.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-06-10T01:24:47.000Z","updated_at":"2024-08-18T21:21:06.000Z","dependencies_parsed_at":"2022-08-24T04:11:39.430Z","dependency_job_id":null,"html_url":"https://github.com/slack-php/slack-php-slick","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slack-php%2Fslack-php-slick","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slack-php%2Fslack-php-slick/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slack-php%2Fslack-php-slick/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slack-php%2Fslack-php-slick/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/slack-php","download_url":"https://codeload.github.com/slack-php/slack-php-slick/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250760669,"owners_count":21482847,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["blockkit","framework","micro-framework","php","slack","slack-api","slack-bot"],"created_at":"2024-11-10T17:17:02.636Z","updated_at":"2025-04-25T05:30:59.783Z","avatar_url":"https://github.com/slack-php.png","language":"PHP","readme":"# Slick (by slack-php)\n\nA _slick_, single-file, dependency-free PHP micro-framework for building simple Slack apps.\n\n**For something more robust, you should use our fully-featured [Slack PHP Framework][1].**\n\nIf you are new to Slack app development, you will want to learn about it on [Slack's website][2].\n\n## Installation\n\n### Requirements\n\nRequires PHP 7.3+ with JSON support.\n\n### Via Composer\n\nWe recommend using Composer to install Slick, so that autoloading and keeping it up-to-date are easy.\n\n```\ncomposer require slack-php/slick\n```\n\n### Manual\n\nHowever, since Slick has no dependencies, you can directly download and require `Slick.php` or copy \u0026 paste the code\ndirectly into your project.\n\n(If you do end up doing this, let me know, because I will have no other way to track that it's happening.)\n\n## Basic Usage\n\nThis small app responds to the `/cool` slash command by posting a message back to the conversation where\nthe slack command was used.\n\n\u003e Assumptions:\n\u003e\n\u003e - You have required the Composer autoloader to autoload Slick, OR you have required `Slick.php` directly.\n\u003e - You have `SLACK_SIGNING_KEY` set in your environment such that it is present in `$_SERVER`.\n\n```php\n\u003c?php\n\nSlackPhp\\Slick::app()\n    -\u003eroute('command', '/cool', function (array $payload) {\n        return \"Thanks for running the `{$payload['command']}` command. You are cool! :thumbsup:\";\n    })\n    -\u003erun();\n```\n\n_Want to run this example in your workspace? Check out the [Example App][3] using Docker._\n\n### Breaking It Down\n\nLet's add some comments to that last example, so you know what is going on.\n\n```php\n\u003c?php\n\n// Create the Slick app object.\nSlackPhp\\Slick::app()\n    // Add a routable listener to the app to handle logic for a specific interaction.\n    -\u003eroute(\n        // The payload type (e.g., command, block_actions, view_submission, shortcut, and others).\n        'command',\n        // The payload ID. It's different based on the type. For commands, it is the command name.\n        '/cool',\n        // The listener that handles the specific interaction's logic.\n        function (array $payload) {\n            // Any app logic can be done here, including calling Slack's APIs.\n            // Whatever you do, it should take less than 3 seconds, so you can \"ack\" before Slack's timeout.\n        \n            // Whatever is returned will be included as part of the \"ack\" (response) body. You can return a string, an\n            // associative array, or JSON-serializable object. You should make sure that anything you include in the ack\n            // is supported by the type of interaction you are responding to. Many interactions don't require an ack\n            // body, so you can also return null, and empty string, or just omit a return statement, entirely.\n            return \"Thanks for running the `{$payload['command']}` command. You are cool! :thumbsup:\";\n        }\n    )\n    // Add as many routes as you need to handle all your interactions.\n    -\u003eroute(...)\n    -\u003eroute(...)\n    -\u003eroute(...)\n    // Runs the Slack app. This includes the following steps:\n    // 1. Reads data from the current request (e.g., via $_SERVER and php://input).\n    // 2. Validates the request from Slack, including verifying the request signature from the header.\n    // 3. Parses the request body into an array of Slack payload data.\n    // 4. Determines the payload type and ID.\n    // 5. Executes one of the registered listeners based on the payload type and ID.\n    // 6. Acks (responds) back to Slack.\n    -\u003erun();\n```\n\n## Customization\n\nThere isn't much to customize, but you can control the behavior of your Slick Slack app when:\n\n1. The incoming request doesn't match one of your routes (`on404()`).\n2. An error occurs while processing the incoming request (`orErr()`).\n\n```php\n\u003c?php\n\nSlackPhp\\Slick::app()\n    -\u003eroute(...)\n    -\u003eroute(...)\n    -\u003eroute(...)\n    -\u003eon404(function (array $payload) {\n        // Do something custom. This is essentially used as a catch-all listener.\n        // If you don't use on404(), then your app throws an error.\n    })\n    -\u003eonErr(function (Throwable $err) {\n        // Do something custom.\n        // If you don't use onErr(), then your app calls `error_log()` and acks with a 500-level response.\n    })\n    -\u003erun();\n```\n\n## Helper Functions\n\nIf you want to do your own request handling, Slick provides some static helper methods that you can use independent from\nthe routing features.\n\n- `Slick::validateSignature(string $key, string $signature, int $time, string $body): void` – Validates a Slack request\n  signature using their v0 algorithm.\n- `Slick::parseRequestBody(string $body): array` – Parses a request body into an associative array of Slack payload\n  data. Works for any payload type. Must provide the raw request body as a string (e.g., from `php://input`).\n- `Slick::getPayloadType(array $payload): string` – Determines the payload type from an array of payload data.\n- `Slick::getPayloadId(array $payload): string` – Determines the payloads routable ID from an array of payload data,\n  based on its type.\n- `Slack::ack(string $ack): void` – Echos an \"ack\" response with suitable headers and status code.\n\n[1]: https://github.com/slack-php/slack-php-app-framework\n[2]: https://api.slack.com/start\n[3]: https://github.com/slack-php/slack-php-slick/tree/main/example\n","funding_links":[],"categories":[":hammer_and_wrench: \u0026nbsp; Libraries and SDKs"],"sub_categories":["PHP"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fslack-php%2Fslack-php-slick","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fslack-php%2Fslack-php-slick","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fslack-php%2Fslack-php-slick/lists"}