PHPackages                             slack-php/slack-block-kit - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. slack-php/slack-block-kit

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

slack-php/slack-block-kit
=========================

OOP interface for writing Slack Block Kit messages and modals

2.3.1(1y ago)55754.2k—7.7%17[4 PRs](https://github.com/slack-php/slack-php-block-kit/pulls)6MITPHPPHP &gt;=8.1CI passing

Since Nov 16Pushed 1y ago2 watchersCompare

[ Source](https://github.com/slack-php/slack-php-block-kit)[ Packagist](https://packagist.org/packages/slack-php/slack-block-kit)[ GitHub Sponsors](https://github.com/jeremeamia)[ RSS](/packages/slack-php-slack-block-kit/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (3)Versions (40)Used By (6)

Slack Block Kit for PHP
=======================

[](#slack-block-kit-for-php)

👉 *For formatting messages and modals for Slack using their Block Kit syntax via an OOP interface* 👈

By Jeremy Lindblom ([@jeremeamia](https://twitter.com/jeremeamia))

 [![Slack logo placed on top of blocks](https://repository-images.githubusercontent.com/358292134/398fbb00-9dbe-11eb-9167-fd67cf034596)](https://repository-images.githubusercontent.com/358292134/398fbb00-9dbe-11eb-9167-fd67cf034596)

 [ ![Coded in PHP 8.1](https://camo.githubusercontent.com/88829803c8d91cb921b9b39c859084da95f60ef9a815b35c632dfd90055c5e11/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f64652d706870253230382e312d3838393262662e737667) ](http://php.net/) [ ![Packagist Version](https://camo.githubusercontent.com/c07ff8562d3176112f27c67a345f5aa2ca1dcf6d2b76d28b026e690fa5c9f0d3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f736c61636b2d7068702f736c61636b2d626c6f636b2d6b69742e737667) ](https://packagist.org/packages/slack-php/slack-block-kit) [ ![Build Status](https://camo.githubusercontent.com/6b6d787d76ab5de4e75013fcfdff629badb5b8d76ae96d652066d0b156b9e005/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e742e7376673f75726c3d6874747073253341253246253246616374696f6e732d62616467652e6174726f782e646576253246736c61636b2d706870253246736c61636b2d7068702d626c6f636b2d6b697425324662616467652533467265662533446d61696e267374796c653d666c6174) ](https://actions-badge.atrox.dev/slack-php/slack-php-block-kit/goto?ref=main)

---

Introduction
------------

[](#introduction)

From Slack's [Block Kit documentation](https://api.slack.com/block-kit):

> **Block Kit** is a UI framework for Slack apps that offers a balance of control and flexibility when building experiences in messages and other *surfaces*.
>
> Customize the order and appearance of information and guide users through your app's capabilities by composing, updating, sequencing, and stacking *blocks* — reusable components that work almost everywhere in Slack.

This library provides an OOP interface in PHP for composing messages/modals using Slack Block Kit. It also does the reverse, meaning you can "hydrate" message/modal JSON into an object hierarchy.

Block Kit Concepts
------------------

[](#block-kit-concepts)

This library helps you build Slack messages and modals programmatically and dynamically in your code, but you need to know how they work generally first. The library does try to prevent you from doing things you are not permitted to do in Block Kit, but it may not validate against every single or condition.

You may want to review the following concepts in the Slack documentation:

- [Surfaces](https://api.slack.com/surfaces) – There are 3 main types: Message, Modal, and App Home
- [Blocks](https://api.slack.com/reference/block-kit/blocks) – Includes *section*, *context*, *actions*, and more
- [Block Elements](https://api.slack.com/reference/block-kit/block-elements) – Includes buttons, menus, text inputs, and other interactive components. We call all of these "Elements" in this library.
- [Composition Objects](https://api.slack.com/reference/block-kit/composition-objects) – We call these "Parts" in the library

In general, we refer to ALL of these different things in Block Kit collectively as "components".

Installation
------------

[](#installation)

Install easily via Composer:

```
composer require slack-php/slack-block-kit
```

Then include the Composer-generated autoloader in your project's initialization code.

**Note**: This library is built for PHP 8.1+.

*[Version 1](https://github.com/slack-php/slack-php-block-kit/tree/v1) of this library supports version 7.3/7.4.*

Basic Usage
-----------

[](#basic-usage)

This library supports an intuitive syntax for composing Slack surfaces (e.g., messages, modals) that utilizes PHP 8's named parameters feature.

```
