PHP Classes

PHP Send Slack Message: Compose and send messages to a Slack channel

Recommend this page to a friend!
  Info   View files Documentation   View files View files (21)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2024-04-19 (Yesterday) RSS 2.0 feedNot yet rated by the usersTotal: 3 This week: 3All time: 11,306 This week: 19Up
Version License PHP version Categories
php-slack 1.0MIT/X Consortium ...7Web services, Chat, PHP 7
Description 

Author

This package can compose and send messages to a Slack channel.

It can send messages to a Slack channel by sending HTTP requests to Slack API.

The package also provides classes that can compose formatted messages with blocks of several types.

Currently, it can compose messages with text, emojis, and buttons in blocks of types like:

- Actions

- Dividers

- Headers

- Sections

Picture of Andrey Iatsenko
  Performance   Level  
Innovation award
Innovation award
Nominee: 5x

 

Documentation

PHPSlack client

> Alas, I do not speak English, and the documentation was compiled through google translator :( > I will be glad if you can help me describe the documentation more correctly :)

:scroll: Installation

The package can be installed via composer:

composer require yzen.dev/php-slack

:scroll: Usage

Common use case:

$config = new Config(
            url:      'https://hooks.slack.com/services/you-token',
            username: 'YouProject',
            channel:  'project-channel',
        );
        $slack = new Slack($config);
        $slack->send([
                         HeaderBlock::create(TextObject::create(text: 'Test message')),
                         DividerBlock::create(),
                         SectionBlock::create(
                             fields: [
                                         TextObject::createMarkdown(text: ":curly_haired_man:User:\n <https://github.com/yzen-dev|yzen.dev>"),
                                         TextObject::createMarkdown(text: ":crown:Role:\n Creator"),
                                     ]
                         ),
                         SectionBlock::create(
                             fields: [
                                         TextObject::createMarkdown(text: ":calendar:When:\n `13.12.2021 23:33`"),
                                     ]
                         ),
                         ActionsBlock::create(
                             elements: [
                                           ButtonObject::create(
                                               text: TextObject::create(text: "Open repository"),
                                               url:  'https://github.com/yzen-dev/php-slack',
                                               style: 'danger'
                                           ),
                                       ]
                         ),
                         DividerBlock::create(),
                     ]);
    }

  Files folder image Files  
File Role Description
Files folder image.github (1 directory)
Files folder imagesrc (2 files, 2 directories)
Files folder imagetests (1 file)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file composer.lock Data Auxiliary data
Accessible without login Plain text file phpcs.xml Data Auxiliary data
Accessible without login Plain text file phpstan.neon Data Auxiliary data
Accessible without login Plain text file phpunit.xml Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation

 Version Control Unique User Downloads Download Rankings  
 100%
Total:3
This week:3
All time:11,306
This week:19Up