Download the PHP package two16d/block-kit-php without Composer
On this page you can find all versions of the php package two16d/block-kit-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download two16d/block-kit-php
More information about two16d/block-kit-php
Files in two16d/block-kit-php
Package block-kit-php
Short Description A fluent PHP builder for creating Slack Block Kit messages
License MIT
Informations about the package block-kit-php
Block Kit PHP
A PHP library for building Slack Block Kit messages programmatically.
Block Kit PHP makes it easier to construct Slack Block Kit payloads in PHP without manually writing JSON. You can build complex modals, messages, and interactive elements using PHP objects, arrays, or method chaining.
Features
- Build Slack Block Kit messages entirely in PHP.
- Supports all Slack Block Kit blocks, surfaces, elements & objects.
- Construct blocks using static helpers or object instances.
- Method chaining for a fluent API.
- Full type hints and docblocks on all methods.
- Strict input validation to ensure payloads comply with Slack's Block Kit rules.
- Convert payloads to JSON or array for Slack API consumption.
- Compatible with PHP 8.1+.
Installation
Install via Composer:
Quick Example
Usage Patterns
Blocks and Classes
Block Kit PHP is organized to reflect Slack's Block Kit model. This helps you compose messages modularly and clearly.
Surfaces
The top-level entry points for creating Slack payloads. All other classes ultimately feed into these surface objects.
- Message:
Surfaces::message(...) - Modal:
Surfaces::modal(...) - App Home (Home Tab):
Surfaces::appHome(...)
Blocks
Blocks are the main structural elements of a Slack message. For example:
- Actions:
Blocks::actions(...) - Section:
Blocks::section(...) - Input:
Blocks::input(...) - Divider, Header, Image, RichText, Table, Video ...
Elements
Elements are interactive components that live inside blocks:
- Button:
Elements::button(...) - Select menus:
Elements::staticSelect(...),Elements::usersSelect(...) - Inputs:
Elements::plainTextInput(...),Elements::datePicker(...) - Checkboxes, Image, Overflow, WorkflowButton ...
Objects
Objects represent smaller data structures used inside blocks or elements:
- Text objects:
Objects::plainText(...),Objects::markdownText(...)- Options and option groups:
Objects::option(...),Objects::optionGroup(...) - Confirmation dialogues (
Objects::confirmationDialog(...)) - Workflow triggers, Slack files, Conversation filters ...
- Options and option groups:
RichText
RichText allows creating Slack’s advanced text formatting blocks. It has its own hierarchy:
- Rich Text Elements:
RichTextElements::section(...),RichTextElements::list(...), ... - Rich Text Objects:
RichTextObjects::text(...),RichTextObjects::link(...), ...
Contributing
- Open a GitHub issue for bugs or feature requests.
- Pull requests should include tests where appropriate.
- Keep code style PSR-12 compliant.
License
MIT License. See LICENSE for details.