Download the PHP package fuwasegu/slack-php-block-kit-next without Composer

On this page you can find all versions of the php package fuwasegu/slack-php-block-kit-next. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package slack-php-block-kit-next

Slack PHP BlockKit NEXT

:point_right: For formatting messages and modals for Slack using their Block Kit syntax via an OOP interface :point_left:

Originally by Jeremy Lindblom (@jeremeamia)

Forked and maintained by Fuwasegu (@fuwasegu)


Warning!

This project is a fork of this, but deviates from the original project.

Introduction

From Slack's Block Kit documentation:

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

This library helps you build Slack messages 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 does not validate or guard against every single rule.

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

In general, we refer to all of the different things in Block Kit collectively as "elements".

Installation

Install easily via Composer:

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

Note: This library is built for PHP 7.3+.

Basic Usage

This library supports an intuitive and fluid syntax for composing Slack surfaces (e.g., messages, modals). The Kit class acts as a façade to the library, and let's you start new messages/modals.

Fluent Interface

When using the fluent interface, every method that sets a property or adds a sub-element returns the original element's object, so you can chain additional method calls.

Methods with a new prefix will return the new element's object, so be careful with how you are using the fluent interface in those cases.

Tapping

Tapping is a way to keep the fluent interface going, but makes sure the whole message is preserved.

Preview in Block Kit Builder

Slack provides an interactive Block Kit Builder for composing/testing messages and other surfaces. This is a great way to play around with and learn the Block Kit format.

The Kit::preview method allows you to render your message/surface as a Block Kit Builder URL, so you can link to a preview or your message/surface in the browser via their interactive tool. This will help you see how it would be rendered in a Slack client.

Output

And here's the actual Block Kit Builder link.

It will show up in the Block Kit Builder looking something like this:

Surface Hydration

Some Slack application integrations (such as with Modals) require receiving the JSON of an existing surface and then modifying or replacing that surface with another. You can "hydrate" the JSON of a surface (or element) into its object representation using its fromArray method (or fromJson).

Message Formatting

The Formatter class exists to provide helpers for formatting "mrkdwn" text. These helpers can be used so that you don't have to have the Slack mrkdwn syntax memorized. Also, these functions will properly escape <, >, and & characters automatically, if it's needed.

Example:

Example Result:

Virtual Elements

In addition to the standard Block Kit elements, the following are virtual/custom elements composed of one or more blocks:

Class Structure

The Kit façade provides ways to create surfaces. Surfaces contain one or more blocks. Blocks are the primary element of the Block Kit. Blocks contain other elements, including other blocks, inputs (interactive elements), and partials (element parts that are not uniquely identifiable).

UML diagram for slack-block-kit

See the YUML
[Kit]-creates>[Surface]
[Surface]^[Message]
[Surface]^[Modal]
[Surface]^[AppHome]
[Surface]^[Attachment]
[Element]^[Surface]
[Element]^[Block]
[Element]^[Input]
[Element]^[Partial]
[Surface]<>->[Block]
[Message]<>->[Attachment]
[Block]<>->[Input]
[Block]<>->[Partial]
[Input]-[note:Examples: Button
DatePicker {bg:cornsilk}]
[Partial]-[note: Examples: Text
Fields {bg:cornsilk}]
[Block]-[note: Examples: Section
Actions {bg:cornsilk}]

All versions of slack-php-block-kit-next with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
ext-json Version *
ext-mbstring Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package fuwasegu/slack-php-block-kit-next contains the following files

Loading the files please wait ....