PHPackages                             bowphp/slack-webhook - 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. [Logging &amp; Monitoring](/categories/logging)
4. /
5. bowphp/slack-webhook

ActiveLibrary[Logging &amp; Monitoring](/categories/logging)

bowphp/slack-webhook
====================

Post messages to your Slack channels with this easy to use library.

1.0.1(1y ago)01.5k1MITPHPPHP &gt;=7.4CI failing

Since Dec 6Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/bowphp/slack)[ Packagist](https://packagist.org/packages/bowphp/slack-webhook)[ Docs](https://github.com/bowphp/slack-webhook)[ RSS](/packages/bowphp-slack-webhook/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (2)Dependencies (2)Versions (4)Used By (1)

Bow Slack Webhook
=================

[](#bow-slack-webhook)

Easy to use PHP library to post messages in Slack using incoming webhook integrations.

Setup
=====

[](#setup)

Log in at [slack.com](slack.com) with your team. Go to the page with all your integrations. Add a new incoming webhook.

Confirm "Add Incoming WebHook integration" Next, you will find your WebHook URL which you need to use this library. Save it somewhere secure.

When you scroll all the way down, you get more options to change your default username, description and icon. You can overwrite these in your code.

Usage
=====

[](#usage)

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

[](#installation)

### Composer

[](#composer)

Install the package via [composer](https://getcomposer.org):

```
composer require bowphp/slack-webhook

```

Add `bowphp/slack-webhook` to your `composer.json` file:

```
{
    "require": {
        "bowphp/slack-webhook": "~1.0"
    }
}
```

Simple message
--------------

[](#simple-message)

```
use Bow\Slack\Slack;
use Bow\Slack\SlackMessage;

// Use the url you got earlier
$webhook = 'https://hooks.slack.com/services/XXXXXXXXX/XXXXXXXXX/XXXXXXXXXXXXXXXXXXXXXXXX';
$slack = new Slack($webhook);

// Create a new message
$message = new SlackMessage;
$message->content("Hello world!");

// Send it!
if ($slack->send($message)) {
    echo "Hurray 😄";
} else {
    echo "Failed 😢";
}
```

Send to a channel
-----------------

[](#send-to-a-channel)

```
// Use the url you got earlier
$slack = new Slack($webhook);

// Create a new message
$message = new SlackMessage;
$message->content("Hello world!")->on("#general");

// Send it!
$slack->send($message);
```

Send to a user
--------------

[](#send-to-a-user)

```
// Use the url you got earlier
$slack = new Slack($webhook);

// Create a new message
$message = new SlackMessage;
$message
  ->content("Hello world!")
  ->on("@simonbackx");

// Send it!
$slack->send($message);
```

Overwriting defaults
--------------------

[](#overwriting-defaults)

You can overwrite the defaults on two levels: in a Slack instance (defaults for all messages using this Slack instance) or SlackMessage instances (only for the current message). These methods will not modify your root defaults at Slack.com, but will overwrite them temporary in your code.

```
$slack = new Slack($webhook);
$message = new SlackMessage;

// Unfurl links: automatically fetch and create attachments for detected URLs
$message->withUnf(true);

// Set the default icon for messages to a custom image
$message->withIcom("http://www.domain.com/robot.png")

// Use a 👻 emoji as default icon for messages if it is not overwritten in messages
$message->withEmoji(":ghost:");

$message->content("Hello world!");

// Set the message channel
$message->on("#general");

// Send it!
$slack->send($message);
```

Attachments
-----------

[](#attachments)

### Create an attachment

[](#create-an-attachment)

Check out  for more details

```
use Bow\Slack\Attachment\SlackAttachment;
use Bow\Slack\SlackMessage;
use Bow\Slack\Slack;

// Use the url you got earlier
$slack = new Slack($webhook);

// Create a new message
$message = new SlackMessage;

$attachment = new SlackAttachment("Required plain-text summary of the attachment.");
$attachment->setColor("#36a64f");
$attachment->setText("*Optional text* that appears within the attachment");
$attachment->setPretext("Optional text that appears above the attachment block");
$attachment->setTitle("Title", "Optional link e.g. http://www.google.com/");
$attachment->setImage("http://www.domain.com/picture.jpg");
$attachment->setAuthor(
    "Author name",
    "http://flickr.com/bobby/", //Optional author link
    "http://flickr.com/bobby/picture.jpg" // Optional author icon
);

/**
 * Slack messages may be formatted using a simple markup language similar to Markdown. Supported
 * formatting includes: ```pre```, `code`, _italic_, *bold*, and even ~strike~.; full details are
 * available on the Slack help site.
 *
 * By default bot message text will be formatted, but attachments are not. To enable formatting on
 * attachment fields, you can use enableMarkdownFor
 */
$attachment->enableMarkdownFor("text");
$attachment->enableMarkdownFor("pretext");
$attachment->enableMarkdownFor("fields");

 // Add fields, last parameter stand for short (smaller field) and is optional
$attachment->addField("Title", "Value");
$attachment->addField("Title2", "Value2", true);
$attachment->addField("Title", "Value", false);

// Add a footer
$attachment->setFooterText('By Simon');
$attachment->setFooterIcon('https://www.simonbackx.com/favicon.png');
$attachment->setTimestamp(time());

// Add it to your message
$message->addAttachment($attachment);

// Send
$slack->send($message);
```

### Add buttons

[](#add-buttons)

```
// Use the url you got earlier
$slack = new Slack('https://hooks.slack.com/services/XXXXXXXXX/XXXXXXXXX/XXXXXXXXXXXXXXXXXXXXXXXX');

// Create a new message
$message = new SlackMessage;
$message->content(" approved your travel request. Book any airline you like by continuing below.");
$message->assignTo('Fly company');

// Create a new Attachment with fallback text, a plain-text summary of the attachment.
// This text will be used in clients that don't show formatted text (eg. IRC, mobile
// notifications) and should not contain any markup.
$attachment = new \SlackAttachment('Book your flights at https://flights.example.com/book/r123456');
$attachment->addButton('Book flights 🛫', 'https://flights.example.com/book/r123456');
$attachment->addButton('Unsubscribe', 'https://flights.example.com/unsubscribe', 'danger');

$message->addAttachment($attachment);

$slack->send($message);
```

### Add (multiple) attachments

[](#add-multiple-attachments)

```
$message = new SlackMessage;

$message->addAttachment($attachment1);
$message->addAttachment($attachment2);

$slack->send($message);
```

### Short syntax

[](#short-syntax)

All methods support a short syntax. E.g.:

```
$message = (new SlackMessage)
    ->addAttachment($attachment1)
    ->addAttachment($attachment2);

$slack->send($message);
```

Testing
=======

[](#testing)

Set the `SLACK_WEBHOOK_URL` variable before

```
composer test
```

Warning
=======

[](#warning)

Each message initiates a new HTTPS request, which takes some time. Don't send too much messages at once if you are not running your script in a background task.

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance62

Regular maintenance activity

Popularity21

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 73.6% 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 ~54 days

Total

2

Last Release

511d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/96099e66c63e31445f3f76a12e94104030f504eeb18f007216bb4ebdcdeadf7f?d=identicon)[papac](/maintainers/papac)

---

Top Contributors

[![SimonBackx](https://avatars.githubusercontent.com/u/5277847?v=4)](https://github.com/SimonBackx "SimonBackx (39 commits)")[![papac](https://avatars.githubusercontent.com/u/9353811?v=4)](https://github.com/papac "papac (9 commits)")[![mikesprague](https://avatars.githubusercontent.com/u/560705?v=4)](https://github.com/mikesprague "mikesprague (4 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")

---

Tags

messageloggingslackwebhookchannels

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/bowphp-slack-webhook/health.svg)

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

###  Alternatives

[simonbackx/slack-php-webhook

Post messages to your Slack channels with this easy to use library.

42857.1k2](/packages/simonbackx-slack-php-webhook)[saasscaleup/laravel-log-alarm

Laravel log Alarm help you to set up alarm when errors occur in your system and send you a notification via Slack and email

26927.9k](/packages/saasscaleup-laravel-log-alarm)[andrey-tech/bitrix24-api-php

Обертка на PHP7+ для работы с API Битрикс24 с использованием механизма входящих вебхуков, троттлингом запросов и логированием в файл

9777.0k](/packages/andrey-tech-bitrix24-api-php)[lefuturiste/monolog-discord-handler

A simple monolog handler for support Discord webhooks

34116.0k4](/packages/lefuturiste-monolog-discord-handler)[thecoder/laravel-monolog-telegram

Telegram Handler for Monolog

2941.1k](/packages/thecoder-laravel-monolog-telegram)

PHPackages © 2026

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