PHPackages                             testmonitor/slack-client - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. testmonitor/slack-client

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

testmonitor/slack-client
========================

The TestMonitor Slack Client.

v2.0.0(2y ago)32.3k↓73.4%2[1 PRs](https://github.com/testmonitor/slack-client/pulls)MITPHPPHP ^8.1

Since Nov 7Pushed 3w ago2 watchersCompare

[ Source](https://github.com/testmonitor/slack-client)[ Packagist](https://packagist.org/packages/testmonitor/slack-client)[ RSS](/packages/testmonitor-slack-client/feed)WikiDiscussions main Synced today

READMEChangelog (2)Dependencies (8)Versions (4)Used By (0)

TestMonitor Slack Client
========================

[](#testmonitor-slack-client)

[![Latest Stable Version](https://camo.githubusercontent.com/6a47767e3d359833a731becb8a0dbb352138f97606ab00edcbe2f02d74b39967/68747470733a2f2f706f7365722e707567782e6f72672f746573746d6f6e69746f722f736c61636b2d636c69656e742f762f737461626c65)](https://packagist.org/packages/testmonitor/slack-client)[![CircleCI](https://camo.githubusercontent.com/7b6a7a2af0056921fe10b57ad2f942678636832f39414ef0b3d2816108a0ac0c/68747470733a2f2f696d672e736869656c64732e696f2f636972636c6563692f70726f6a6563742f6769746875622f746573746d6f6e69746f722f736c61636b2d636c69656e742e737667)](https://circleci.com/gh/testmonitor/slack-client)[![StyleCI](https://camo.githubusercontent.com/aa68d58d1aec23e391609ec6a93a003e7cff6bea4557e96f06bb7daa72c58c0b/68747470733a2f2f7374796c6563692e696f2f7265706f732f3430313634373538312f736869656c64)](https://styleci.io/repos/401647581)[![codecov](https://camo.githubusercontent.com/9385bab3715fed652fbd22c54a0a439340454f98cd31fc897fcd3d813f859b64/68747470733a2f2f636f6465636f762e696f2f67682f746573746d6f6e69746f722f736c61636b2d636c69656e742f67726170682f62616467652e7376673f746f6b656e3d365a3551495953513652)](https://codecov.io/gh/testmonitor/slack-client)[![License](https://camo.githubusercontent.com/cc91a86dd16eede045fc37045bd3d0063b08b46952a67ba691beace72084d31c/68747470733a2f2f706f7365722e707567782e6f72672f746573746d6f6e69746f722f736c61636b2d636c69656e742f6c6963656e7365)](https://packagist.org/packages/testmonitor/slack-client)

This package provides a very basic, convenient, and unified wrapper for sending posts to Slack. Out of the box, it comes with:

- Slack V2 OAuth 2.0 protocol for authentication (inspired by the [Slack Provider for OAuth 2.0 Client](https://github.com/adam-paterson/oauth2-slack)).
- The [Slack Block Kit for PHP](https://github.com/slack-php/slack-php-block-kit), a library that provides an OOP interface in PHP for composing messages/modals.

Table of Contents
-----------------

[](#table-of-contents)

- [Installation](#installation)
- [Usage](#usage)
- [Examples](#examples)
- [Tests](#tests)
- [Changelog](#changelog)
- [Contributing](#contributing)
- [Credits](#credits)
- [License](#license)

Installation
------------

[](#installation)

To install the client you need to require the package using composer:

```
$ composer require testmonitor/slack-client

```

Use composer's autoload:

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

You're all set up now!

Usage
-----

[](#usage)

This client only supports **oAuth 2.0 authentication**. You'll need a Slack application to proceed. If you haven't done so, please read up with the [Slack authentication API docs](https://api.slack.com/authentication) on how to create an application.

When you already have an application available, make sure it's a new Slack app, as this package does not support Slack classic apps. To learn more about the differences between classic and new Slack apps, refer to the [differences between old and new Slack apps](https://api.slack.com/authentication/quickstart).

When your Slack application is up and running, start with the oAuth authorization:

```
$oauth = [
    'clientId' => '12345',
    'clientSecret' => 'abcdef',
    'redirectUri' => 'https://redirect.myapp.com/',
];

$slack = new \TestMonitor\Slack\Client($oauth);

header('Location: ' . $slack->authorizationUrl('incoming-webhook', 'state'));
exit();
```

This will redirect the user to a page asking confirmation for your app getting access to Slack. Make sure your redirectUrl points back to your app. Slack will provide you with a temporary code that allows you to create an access code that can be used for authentication. Route the redirect URL to the following code:

```
$oauth = [
    'clientId' => '12345',
    'clientSecret' => 'abcdef',
    'redirectUri' => 'https://redirect.myapp.com/',
];

$slack = new \TestMonitor\Slack\Client($oauth);

$token = $slack->fetchToken($_REQUEST['code']);
```

When everything went ok, you should have an access token (available through AccessToken object). The AccessToken contains all the information you should need to post a message using a webhook:

```
var_dump ($token->getValues());

array() {
    ["ok"] => true
    ["app_id"] => "APPID"
    ["authed_user"] => array(1) {}
    ["scope"] => "incoming-webhook"
    ["token_type"] => "bot"
    ["bot_user_id"] => "USERID"
    ["team"] => array(2) {}
    ["enterprise"] => null
    ["is_enterprise_install"] => false
    ["incoming_webhook"] => array(4) {
      ["channel"] => "#testmonitor"
      ["channel_id"] => "CHANNELID"
      ["configuration_url"] => "https://domain.slack.com/services/B123456USA"
      ["url"] => "https://hooks.slack.com/services/T123456/B123456USA/tEsTm0n1t0r"
    }
```

Make sure to save incoming webhook URL in your database, you'll need this later to post messages.

In case your Slack app is not configured for token rotation, you're all done now!

When token rotation has been enabled, your access token will be valid for **twelve hours**. After that, you'll have to refresh the token to regain access:

```
$oauth = ['clientId' => '12345', 'clientSecret' => 'abcdef', 'redirectUri' => 'https://redirect.myapp.com/'];
$token = new \TestMonitor\Slack\Token('eyJ0...', '0/34ccc...', 1574600877); // the token you got last time

$slack = new \TestMonitor\Slack\Client($oauth, $token);

if ($token->expired()) {
    $newToken = $slack->refreshToken();
}
```

The new token will be valid again for the next twelve hours.

Examples
--------

[](#examples)

Post a simple message to Slack:

```
$message = Kit::newMessage()->text('Hello world!');

$slack->postMessage('https://webhook.url/', $message);
```

Block Kit allows you to create way more comprehensive messages. Here's another example:

```
$user = (object) ['name' => 'John Doe'];

$message = Kit::newMessage()
    ->tap(function (Message $message) {
        $message->newSection()
            ->mrkdwnText("*{$user->name}* created a new issue");
    })
    ->divider()
    ->tap(function (Message $message) {
        $message->newContext()
            ->mrkdwnText('Status: *Open*')
            ->mrkdwnText('Priority: *High*')
            ->mrkdwnText('Resolution: *Unresolved*');
    })

$slack->postMessage('https://webhook.url/', $message);
```

For more information on composing messages with Block Kit, head over to the [Slack Block Kit for PHP documentation](https://github.com/slack-php/slack-php-block-kit) or refer to the official [Slack Block Kit documentation](https://api.slack.com/block-kit).

Tests
-----

[](#tests)

The package contains integration tests. You can run them using PHPUnit.

```
$ vendor/bin/phpunit

```

Changelog
---------

[](#changelog)

Refer to [CHANGELOG](CHANGELOG.md) for more information.

Contributing
------------

[](#contributing)

Refer to [CONTRIBUTING](CONTRIBUTING.md) for contributing details.

Credits
-------

[](#credits)

- **Thijs Kok** - *Lead developer* - [ThijsKok](https://github.com/thijskok)
- **Stephan Grootveld** - *Developer* - [Stefanius](https://github.com/stefanius)
- **Frank Keulen** - *Developer* - [FrankIsGek](https://github.com/frankisgek)
- **Muriel Nooder** - *Developer* - [ThaNoodle](https://github.com/thanoodle)

License
-------

[](#license)

The MIT License (MIT). Refer to the [License](LICENSE.md) for more information.

###  Health Score

43

—

FairBetter than 89% of packages

Maintenance62

Regular maintenance activity

Popularity23

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 61% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~884 days

Total

2

Last Release

815d ago

Major Versions

v1.0.0 → v2.0.02024-04-10

PHP version history (2 changes)v1.0.0PHP ^8.0

v2.0.0PHP ^8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/39f48c881813b7d3b044ca5660aa5ab9e60b5dd7c34ed4a47acbb11bd20b7593?d=identicon)[thijskok](/maintainers/thijskok)

---

Top Contributors

[![thijskok](https://avatars.githubusercontent.com/u/1344550?v=4)](https://github.com/thijskok "thijskok (36 commits)")[![stefanius](https://avatars.githubusercontent.com/u/2707905?v=4)](https://github.com/stefanius "stefanius (21 commits)")[![Frankisgek](https://avatars.githubusercontent.com/u/487218?v=4)](https://github.com/Frankisgek "Frankisgek (1 commits)")[![StyleCIBot](https://avatars.githubusercontent.com/u/11048387?v=4)](https://github.com/StyleCIBot "StyleCIBot (1 commits)")

---

Tags

slacktestmonitorclientslacktestmonitor

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/testmonitor-slack-client/health.svg)

```
[![Health](https://phpackages.com/badges/testmonitor-slack-client/health.svg)](https://phpackages.com/packages/testmonitor-slack-client)
```

###  Alternatives

[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k15](/packages/tempest-framework)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

751291.4k43](/packages/civicrm-civicrm-core)[neuron-core/neuron-ai

The PHP Agentic Framework.

2.0k656.1k38](/packages/neuron-core-neuron-ai)[spatie/laravel-export

Create a static site bundle from a Laravel app

674146.0k6](/packages/spatie-laravel-export)[oat-sa/tao-core

TAO core extension

66143.7k124](/packages/oat-sa-tao-core)[eslazarev/wildberries-sdk

Wildberries OpenAPI clients (generated).

273.0k](/packages/eslazarev-wildberries-sdk)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
