1. Go to this page and download the library: Download ntimyeboah/php-slack library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ntimyeboah / php-slack example snippets
use NtimYeboah\PhpSlack\SlackMessage;
(new SlackMessage)
->token('xoxb-123abc')
->channel('general')
->text('Hello')
->send();
use NtimYeboah\PhpSlack\Credentials
$credentials = Credentials::make('general', 'xoxb-123abc');
$slackMessage = new SlackMessage($credentials);
$slackMessage->text('Hello')
$slackMessage->send();
use NtimYeboah\PhpSlack\Credentials;
use NtimYeboah\PhpSlack\BlockKit\Blocks\Section;
$credentials = Credentials::make('general', 'xoxb-123abc');
(new SlackMessage($credentials))
->section(function (Section $section) {
$section->field('This is a field')->markdown();
$section->field('This is another field');
})
->send();
use NtimYeboah\PhpSlack\Credentials;
use NtimYeboah\PhpSlack\BlockKit\Blocks\Context;
$credentials = Credentials::make('general', 'xoxb-123abc');
(new SlackMessage($credentials))
->context(function (Context $block) {
$block->text("*This* is :smile markdown")->markdown();
$block->image('http://path/to/image.jpg')->altText('cute cat');
$block->text('This is a plain text');
})
->send()
use NtimYeboah\PhpSlack\Credentials;
use NtimYeboah\PhpSlack\BlockKit\Blocks\Header;
$credentials = Credentials::make('general', 'xoxb-123abc');
(new SlackMessage($credentials))
->header(function (Header $block) {
$block->text('This is a header text');
})
->send();
use NtimYeboah\PhpSlack\Credentials;
use NtimYeboah\PhpSlack\BlockKit\Blocks\RichText;
$credentials = Credentials::make('general', 'xoxb-123abc');
(new SlackMessage($credentials))
->richText(function (RichText $block) {
$block->text('This is a text');
$block->text('This is a bold text')->bold();
$block->text('This is an italic text')->italic();
$block->text('This is a strikethrough text')->strike();
$block->emoji('basketball');
})
->send();
use NtimYeboah\PhpSlack\Credentials;
$credentials = Credentials::make('general', 'xoxb-123abc');
(new SlackMessage($credentials))
->divider()
->send();
bash
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.