2017 © Pedro Peláez
 

library slack-notifications

A PHP interface for sending Notifications to your Slack team

image

jc21/slack-notifications

A PHP interface for sending Notifications to your Slack team

  • Monday, January 29, 2018
  • by jc21
  • Repository
  • 2 Watchers
  • 1 Stars
  • 1,828 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 3 % Grown

The README.md

Slack Notifications from your PHP App

  • Send to any Channel or User
  • Full webhook options set supported
  • Attachments for nice field data display

Installing via Composer

# Install Composer
curl -sS https://getcomposer.org/installer | php

Next, run the Composer command to install the latest stable version:, (*1)

composer.phar require jc21/slack-notifications

After installing, you need to require Composer's autoloader:, (*2)

require 'vendor/autoload.php';

Using

Class documentation, (*3)

See the tests folder for some examples, but basically here's how to use it:, (*4)

use jc21\SlackNotification;
use jc21\SlackAttachment;

$webhookUrl = 'your incoming webhook url';
$iconURl    = '';

// Create Attachment first
$attachment = new SlackAttachment();
$attachment->setFallback('Someone has tested the slack-notifications code successfully');
$attachment->setPretext('<https://github.com/jc21/slack-notifications|slack-notifications> was tested');
$attachment->setColor('#00ce3a');
$attachment->setAuthorName('Jamie Curnow');
$attachment->setAuthorLink('http://jc21.com');
$attachment->setAuthorIcon('https://avatars2.githubusercontent.com/u/1518257?v=3&s=460');

// Fields of the Attachment
$attachment->addField('Description', 'slack-notifications is a PHP package to help you out', false);
$attachment->addField('Type',        'Test',                                                 true);
$attachment->addField('Result',      'Success',                                              true);

// The notification, which uses the Attachment
$notification = new SlackNotification($webhookUrl);
$notification->setChannel('#general');  // Use @ for a username. ie: @jc21
$notification->setUsername('slack-notifications');
$notification->setIconUrl($iconUrl);
$notification->addAttachment($attachment);

try {
    $notification->send();
} catch (\Exception $e) {
    print 'Error: ' . $e->getMessage() . PHP_EOL;
    exit(1);
}

The Versions

29/01 2018

dev-master

9999999-dev https://github.com/jc21/slack-notifications

A PHP interface for sending Notifications to your Slack team

  Sources   Download

BSD BSD-1-Clause

The Requires

  • php >=5.3.0

 

The Development Requires

by Jamie Curnow

notification slack

19/08 2015

1.3

1.3.0.0 https://github.com/jc21/slack-notifications

A PHP interface for sending Notifications to your Slack team

  Sources   Download

BSD

The Requires

  • php >=5.3.0

 

The Development Requires

by Jamie Curnow

notification slack

29/06 2015

1.2

1.2.0.0 https://github.com/jc21/slack-notifications

A PHP interface for sending Notifications to your Slack team

  Sources   Download

BSD

The Requires

  • php >=5.3.0

 

by Jamie Curnow

notification slack

29/06 2015

1.1

1.1.0.0 https://github.com/jc21/slack-notifications

A PHP interface for sending Notifications to your Slack team

  Sources   Download

BSD

The Requires

  • php >=5.3.0

 

by Jamie Curnow

notification slack