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  
Name: Andrey Iatsenko <contact>
Classes: 9 packages by
Country: Russian Federation Russian Federation
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

  Files folder image Files  /  .github  
File Role Description
Files folder imageworkflows (1 file)

  Files folder image Files  /  .github  /  workflows  
File Role Description
  Accessible without login Plain text file php.yml Data Auxiliary data

  Files folder image Files  /  src  
File Role Description
Files folder imageBlockKit (5 files, 2 directories)
Files folder imageException (1 file)
  Plain text file Config.php Class Class source
  Plain text file Slack.php Class Class source

  Files folder image Files  /  src  /  BlockKit  
File Role Description
Files folder imageBlockElements (2 files)
Files folder imageCompositionObjects (3 files)
  Plain text file AbstractBlock.php Class Class source
  Plain text file ActionsBlock.php Class Class source
  Plain text file DividerBlock.php Class Class source
  Plain text file HeaderBlock.php Class Class source
  Plain text file SectionBlock.php Class Class source

  Files folder image Files  /  src  /  BlockKit  /  BlockElements  
File Role Description
  Plain text file AbstractObject.php Class Class source
  Plain text file ButtonObject.php Class Class source

  Files folder image Files  /  src  /  BlockKit  /  CompositionObjects  
File Role Description
  Plain text file AbstractObject.php Class Class source
  Plain text file AccessoryObject.php Class Class source
  Plain text file TextObject.php Class Class source

  Files folder image Files  /  src  /  Exception  
File Role Description
  Plain text file InvalidArgumentException.php Class Class source

  Files folder image Files  /  tests  
File Role Description
  Plain text file SlackClientTest.php Class Class source

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