PHP Classes

File: README.md

Recommend this page to a friend!
  Classes of Andrey Iatsenko   PHP Send Slack Message   README.md   Download  
File: README.md
Role: Documentation
Content type: text/markdown
Description: Documentation
Class: PHP Send Slack Message
Compose and send messages to a Slack channel
Author: By
Last change:
Date: 13 days ago
Size: 2,022 bytes
 

Contents

Class file image Download

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(),
                     ]);
    }