2017 © Pedro Peláez
 

library slacker

Slack notifier

image

cromwell/slacker

Slack notifier

  • Wednesday, February 15, 2017
  • by ben.cromwell
  • Repository
  • 1 Watchers
  • 0 Stars
  • 52 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 6 Versions
  • 0 % Grown

The README.md

php-slacker

A quick Slack notifier for PHP, (*1)

Simplified usage

<?php

require __DIR__ . '/vendor/autoload.php';

// setup with a configured Guzzle client
$slacker = new \Slacker\Slack(
    $config['webhook'],
    new \GuzzleHttp\Client()
);

// or with a default Guzzle client you need not pass it in
$slacker = new \Slacker\Slack($config['webhook']);

$slacker
    ->channel('#general')
    ->username('Slacker')
    ->message('Hello, #general')
    ->send();

// Or simpler, using the defaults chosen for the webook within Slack:
$slacker->message('Hello!')->send();

Calls to channel or username persist across uses, whereas calls to message reset the message and the attachment., (*2)

Regular usage

<?php

require __DIR__ . '/vendor/autoload.php';

$config = require(__DIR__ . '/slack-config.php');

// general setup
$slackPoster = new \Slacker\SlackPoster(
    new \GuzzleHttp\Client(),
    $config['hookUri']
);

$payload = new \Slacker\Payload\Payload();
$payload->username = $config['username'];
$payload->channel = $config['channel'];

// specific message setup
$payload->text = 'General Message Text';

$attachment = new \Slacker\Payload\Attachment();
$attachment->color = 'good';
$attachment->fallback = 'some fallback message';

$field = new \Slacker\Payload\Field();
$field->short = 'Field Short Message';
$field->title = 'Field Title';
$field->value = 'Field Value';
$attachment->addField($field);

$field = new \Slacker\Payload\Field();
$field->short = 'Field Short Message 2';
$field->title = 'Field Title 2';
$field->value = 'Field Value 2';
$attachment->addField($field);

$field = new \Slacker\Payload\Field();
$field->short = 'Field Short Message 3';
$field->title = 'Field Title 3';
$field->value = 'Field Value 3';
$attachment->addField($field);

$payload->addAttachment($attachment);

// send the message
$slackPoster->send($payload);

The Versions

15/02 2017

dev-master

9999999-dev

Slack notifier

  Sources   Download

MIT

The Requires

 

The Development Requires

slack

15/02 2017

0.5

0.5.0.0

Slack notifier

  Sources   Download

MIT

The Requires

 

The Development Requires

slack

15/02 2017

0.4

0.4.0.0

Slack notifier

  Sources   Download

MIT

The Requires

 

The Development Requires

slack

15/02 2017

0.3

0.3.0.0

Slack notifier

  Sources   Download

MIT

The Requires

 

slack

31/03 2016

0.2

0.2.0.0

Slack notifier

  Sources   Download

MIT

The Requires

 

slack

05/01 2016

0.1

0.1.0.0

Slack notifier

  Sources   Download

MIT

The Requires

 

slack