PHP code example of coolin / slack-messenger

1. Go to this page and download the library: Download coolin/slack-messenger 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/ */

    

coolin / slack-messenger example snippets


  /** @var \Coolin\SlackMessenger\Messenger @inject*/
  public $slack;
  
  public function send(){
    //variant 1    
    $this->slack->send('Your Message');
    
    //variant 2
    $message = new \Coolin\SlackMessenger\Message();
    $message->setChannel('#general');
    $message->setName('Awesome Bot');
    $message->setText('I\'m alive!');
    
    $this->slack->sendMessage($message);
    $this->slack->sendMessage($message, null, self::ALT_SLACK_HOOK); // ignore Slack hook from config and use specific one
  }

$message->setText('Normal text ' . Formatter::bold('bold text'));