2017 © Pedro Peláez
 

library php-slackbot

Simple, easy to use, PHP package for sending messages to Slack. Send pretty, colourful messages with rich attachments quickly with this friendly API

image

lygav/php-slackbot

Simple, easy to use, PHP package for sending messages to Slack. Send pretty, colourful messages with rich attachments quickly with this friendly API

  • Thursday, December 1, 2016
  • by lygav
  • Repository
  • 5 Watchers
  • 36 Stars
  • 26,841 Installations
  • PHP
  • 3 Dependents
  • 1 Suggesters
  • 5 Forks
  • 0 Open issues
  • 5 Versions
  • 17 % Grown

The README.md

PHP-SlackBot Packagist

Build Status Scrutinizer Packagist Packagist Pre Release, (*1)

Simple, easy to use, PHP package for sending messages to Slack.
Send pretty, colourful messages with rich attachments quickly with this friendly API., (*2)

Compatible with PHP >= 5.3, (*3)

Installation

Via composer

"require": {
   "lygav/php-slackbot": "0.0.*"
}

Without composer, via PHAR

From the command line, enter into the cloned repository dir and run:, (*4)

php makephar

You will see that a new file was created named "phpslackbot.phar". Then in your application:, (*5)

include 'path/to/phpslackbot.phar';

The rest is the same as when installed with 'composer', (*6)

Your first message

$bot = new Slackbot("https://hooks.slack.com/services/your/incoming/hook");
$bot->text("Hi")->send();

Direct messages

$bot->text("Hi all!")
    ->from("username")
    ->toChannel("mychannel")
    ->send();

Create pretty, colorful attachments easily

$bot->attach(
    $bot->buildAttachment("fallback text")
    ->enableMarkdown()
    ->setText("We can have *mrkdwn* `code` _italic_ also in attachments")
    )
    ->toGroup("mygroup")
    ->send();

Customise freely

$attachment = $bot->buildAttachment("fallback text"/* mandatory by slack */)
    ->setPretext("pretext line")
    ->setText("attachment body text")
    /*
      Human web-safe colors automatically
      translated into HEX equivalent
    */
    ->setColor("lightblue")
    ->setAuthor("me")
    ->addField("short field", "i'm inline", TRUE)
    ->addField("short field 2", "i'm also inline", TRUE)
    ->setImageUrl("http://my-website.com/path/to/image.jpg");

$bot->attach($attachment)->send();

Set/ Override every possible setting

$options = array(
            'username' => 'my-bot-name',
            'icon_emoji' => ':icon name:',
            'icon_url' => 'http://someicon.com',
            'channel' => '#test-channel'
        );

$bot = new Slackbot($url, $options);
$bot->text("check out bot new icon")->send();

// Choose to override 'last minute' (ex. when dealing with multiple consequtive messages)
$bot->text("check out bot new icon")->send(array("username" => "other-bot-name"));

Advanced Usage

Use custom transfer handlers

$handler = new MockHandler();
$bot     = new SlackBot($url, ['handler' => $handler]);
$bot->text("some text")
    ->from("my-test-bot")
    ->toGroup("bot-testing")
    ->send();

The Versions

01/12 2016

dev-master

9999999-dev https://github.com/lygav/php-slackbot

Simple, easy to use, PHP package for sending messages to Slack. Send pretty, colourful messages with rich attachments quickly with this friendly API

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

slack slackbot php-slackbot

01/12 2016

0.0.4

0.0.4.0 https://github.com/lygav/php-slackbot

Simple, easy to use, PHP package for sending messages to Slack. Send pretty, colourful messages with rich attachments quickly with this friendly API

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

slack slackbot php-slackbot

15/09 2015

0.0.3

0.0.3.0

Simple, easy to use, PHP package for sending messages to Slack. Send pretty, colourful messages with rich attachments quickly with this friendly API

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

by Vladi Lyga

06/09 2015

0.0.2

0.0.2.0

A simple, easy to use, fully featured PHP package for sending messages to Slack incoming webhook.

  Sources   Download

MIT

The Development Requires

by Vladi Lyga

06/07 2015

0.0.1

0.0.1.0

A simple, easy to use, fully featured PHP package for sending messages to Slack incoming webhook.

  Sources   Download

MIT

The Development Requires

by Vladi Lyga