Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
  scripts
  src
  .gitignore
  .travis.yml
  README.md
  composer.json
Size: Mime:
  README.md

php-slack

A simple Slack Client implementation, which allows async and sync message delivery.

Install

Run composer require crazyfactory/slack to install the latest version into your composer powered project.

Usage

Basic usage example

The client only requires This class is meant to be instantiated to be used.

// bootstrap your autolaoder
require '../vendor/autoload.php';

// instantiate SlackClient
$slack = new SlackClient("http://my-slack-webhook.example.com");

// send a message
$slack->send("Hello World!");

Comples usage example

On construction we can pass in an extended configuration object

// bootstrap your autolaoder
require '../vendor/autoload.php';

// instantiate SlackClient
$slack = new SlackClient([
    "endpoint" => "http://my-slack-webhook.example.com",
    "context" => [
        "username" => "my_bot_name"
    ]
]);

When sending we can also supply a more complex message context. Have a look at the Slack Incoming Webhooks documentation for this.

// send a message
$slack->send([
    "text" => "Hello World!",
    "attachments": [
        {
            "title": "Title",
            "pretext": "Pretext _supports_ mrkdwn",
            "text": "Testing *right now!*",
            "mrkdwn_in": ["text", "pretext"]
        }
    ]
]);

Changelog

  • 2.0.1: support php 5.6
  • 2.0.0: now with autodeploy