PHP Classes

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

Recommend this page to a friend!
  Info   Documentation   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2024-04-19 (5 months ago) RSS 2.0 feedNot enough user ratingsTotal: 27 All time: 11,180 This week: 73Up
Version License PHP version Categories
php-slack 1.0.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: 11 packages by
Country: Russian Federation Russian Federation
Age: 29
All time rank: 4243117 in Russian Federation Russian Federation
Week rank: 46 Up4 in Russian Federation Russian Federation Up
Innovation award
Innovation award
Nominee: 7x

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 (21)  
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 (21)  /  .github  
File Role Description
Files folder imageworkflows (1 file)

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

  Files folder image Files (21)  /  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 (21)  /  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 (21)  /  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 (21)  /  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 (21)  /  src  /  Exception  
File Role Description
  Plain text file InvalidArgumentException.php Class Class source

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

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:27
This week:0
All time:11,180
This week:73Up