PHPackages                             jeremykenedy/slack - 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. [Mail &amp; Notifications](/categories/mail)
4. /
5. jeremykenedy/slack

ActiveLibrary[Mail &amp; Notifications](/categories/mail)

jeremykenedy/slack
==================

A simple PHP package for sending messages to Slack.

v2.4.0(5y ago)10895.4k↓10.1%21MITPHPPHP &gt;=5.5.0CI failing

Since Jul 21Pushed 5y ago1 watchersCompare

[ Source](https://github.com/jeremykenedy/slack)[ Packagist](https://packagist.org/packages/jeremykenedy/slack)[ RSS](/packages/jeremykenedy-slack/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (3)Versions (6)Used By (1)

Slack for PHP
=============

[](#slack-for-php)

[![Total Downloads](https://camo.githubusercontent.com/081d4ea3da50c1759a01c07d10ae8e69a9bb37bedcfa31c2ac23d04b8ca4c7f2/68747470733a2f2f706f7365722e707567782e6f72672f6a6572656d796b656e6564792f736c61636b2f642f746f74616c2e737667)](https://packagist.org/packages/jeremykenedy/slack)[![Latest Stable Version](https://camo.githubusercontent.com/ca67195d2d36fd358bbeefcca5f3869f2f439c842092e1ccbf09df900beb17fb/68747470733a2f2f706f7365722e707567782e6f72672f6a6572656d796b656e6564792f736c61636b2f762f737461626c652e737667)](https://packagist.org/packages/jeremykenedy/slack)[![Build Status](https://camo.githubusercontent.com/a0e5eb5b36e8bef689a6caf28b14597bbacd458050583f6fde7a0c1df3c3618d/68747470733a2f2f7472617669732d63692e636f6d2f6a6572656d796b656e6564792f736c61636b2e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/jeremykenedy/slack)[![StyleCI](https://camo.githubusercontent.com/47810fe2e404d964e8aaaf8344d11a4544b48c44691b10f465c3fa7e3c7841e5/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f39373937313135322f736869656c643f6272616e63683d6d6173746572)](https://github.styleci.io/repos/97971152?branch=master)[![License: MIT](https://camo.githubusercontent.com/fdf2982b9f5d7489dcf44570e714e3a15fce6253e0cc6b5aa61a075aac2ff71b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f772e737667)](https://opensource.org/licenses/MIT)

A simple PHP package for sending messages to [Slack](https://slack.com) with [incoming webhooks](https://my.slack.com/services/new/incoming-webhook).

- Laravel integration: [Slack for Laravel](https://github.com/jeremykenedy/slack-laravel)

- [Requirements](#requirements)
- [Installation](#installation)
- [Basic Usage](#basic-usage)
    - [Instantiate the client](#instantiate-the-client)
    - [Settings](#settings)
    - [Sending Messages](#sending-messages)
        - [Sending a basic message](#sending-a-basic-message)
        - [Sending a message to a non-default channel](#sending-a-message-to-a-non-default-channel)
        - [Sending a message to a user](#sending-a-message-to-a-user)
        - [Sending a message to a channel as a different bot name](#sending-a-message-to-a-channel-as-a-different-bot-name)
        - [Sending a message with a different icon](#sending-a-message-with-a-different-icon)
        - [Send an attachment](#send-an-attachment)
        - [Send an attachment with fields](#send-an-attachment-with-fields)
        - [Send an attachment with an author](#send-an-attachment-with-an-author)
- [Advanced Usage](#advanced-usage)
    - [Markdown](#markdown)
    - [Send a message enabling or disabling Markdown](#send-a-message-enabling-or-disabling-Markdown)
    - [Send an attachment specifying which fields should have Markdown enabled](#send-an-attachment-specifying-which-fields-should-have-Markdown-enabled)
    - [Explicit message creation](#explicit-message-creation)
    - [Attachments](#attachments)
- [Contributing](#contributing)
- [Credits](#credits)
- [License](#license)

### Requirements

[](#requirements)

- PHP 7.3, 7.4+

### Installation

[](#installation)

##### 1. From your projects root folder in terminal run:

[](#1-from-your-projects-root-folder-in-terminal-run)

```
    composer require jeremykenedy/slack
```

##### 2. Create Webhook

[](#2-create-webhook)

```
* [Create an incoming webhook](https://my.slack.com/services/new/incoming-webhook) on your Slack account for the package to use. You'll need the webhook URL to instantiate the client (or for the configuration file if using Laravel).

```

### Basic Usage

[](#basic-usage)

#### Instantiate the client

[](#instantiate-the-client)

```
// Instantiate without defaults
$client = new jeremykenedy\Slack\Client('https://hooks.slack.com/...');

// Instantiate with defaults, so all messages created
// will be sent from 'Cyril' and to the #accounting channel
// by default. Any names like @jeremykenedy or #channel will also be linked.
$settings = [
	'username' => 'Cyril',
	'channel' => '#accounting',
	'link_names' => true
];

$client = new jeremykenedy\Slack\Client('https://hooks.slack.com/...', $settings);
```

##### Settings

[](#settings)

The default settings are pretty good, but you may wish to set up default behaviour for your client to be used for all messages sent. **All settings are optional and you don't need to provide any**. Where not provided, we'll fallback to what is configured on the webhook integration, which are [managed at Slack](https://my.slack.com/apps/manage/custom-integrations), or our sensible defaults.

FieldTypeDescription`channel`stringThe default channel that messages will be sent to`username`stringThe default username for your bot`icon`stringThe default icon that messages will be sent with, either `:emoji:` or a URL to an image`link_names`boolWhether names like `@jeremykenedy` or `#accounting` should be linked in the message (defaults to false)`unfurl_links`boolWhether Slack should unfurl text-based URLs (defaults to false)`unfurl_media`boolWhether Slack should unfurl media-based URLs, like tweets or Youtube videos (defaults to true)`allow_markdown`boolWhether markdown should be parsed in messages, or left as plain text (defaults to true)`markdown_in_attachments`arrayWhich attachment fields should have markdown parsed (defaults to none)#### Sending Messages

[](#sending-messages)

##### Sending a basic message

[](#sending-a-basic-message)

```
$client->send('Hello world!');
```

##### Sending a message to a non-default channel

[](#sending-a-message-to-a-non-default-channel)

```
$client->to('#accounting')->send('Are we rich yet?');
```

##### Sending a message to a user

[](#sending-a-message-to-a-user)

```
$client->to('@jeremykenedy')->send('Yo!');
```

##### Sending a message to a channel as a different bot name

[](#sending-a-message-to-a-channel-as-a-different-bot-name)

```
$client->from('Jake the Dog')->to('@FinnTheHuman')->send('Adventure time!');
```

##### Sending a message with a different icon

[](#sending-a-message-with-a-different-icon)

```
// Either with a Slack emoji
$client->to('@jeremykenedy')->withIcon(':ghost:')->send('Boo!');

// or a URL
$client->to('#accounting')->withIcon('http://example.com/accounting.png')->send('Some accounting notification');
```

#### Send an attachment

[](#send-an-attachment)

```
$client->to('#operations')->attach([
	'fallback' => 'Server health: good',
	'text' => 'Server health: good',
	'color' => 'danger',
])->send('New alert from the monitoring system'); // no message, but can be provided if you'd like
```

#### Send an attachment with fields

[](#send-an-attachment-with-fields)

```
$client->to('#operations')->attach([
	'fallback' => 'Current server stats',
	'text' => 'Current server stats',
	'color' => 'danger',
	'fields' => [
		[
			'title' => 'CPU usage',
			'value' => '90%',
			'short' => true // whether the field is short enough to sit side-by-side other fields, defaults to false
		],
		[
			'title' => 'RAM usage',
			'value' => '2.5GB of 4GB',
			'short' => true
		]
	]
])->send('New alert from the monitoring system'); // no message, but can be provided if you'd like
```

#### Send an attachment with an author

[](#send-an-attachment-with-an-author)

```
$client->to('@jeremykenedy')->attach([
	'fallback' => 'Keep up the great work! I really love how the app works.',
	'text' => 'Keep up the great work! I really love how the app works.',
	'author_name' => 'Jane Appleseed',
	'author_link' => 'https://yourapp.com/feedback/5874601',
	'author_icon' => 'https://static.pexels.com/photos/61120/pexels-photo-61120-large.jpeg'
])->send('New user feedback');
```

### Advanced usage

[](#advanced-usage)

#### Markdown

[](#markdown)

By default, Markdown is enabled for message text, but disabled for attachment fields. This behaviour can be configured in settings, or on the fly:

##### Send a message enabling or disabling Markdown

[](#send-a-message-enabling-or-disabling-markdown)

```
$client->to('#weird')->disableMarkdown()->send('Disable *markdown* just for this message');

$client->to('#general')->enableMarkdown()->send('Enable _markdown_ just for this message');
```

##### Send an attachment specifying which fields should have Markdown enabled

[](#send-an-attachment-specifying-which-fields-should-have-markdown-enabled)

```
$client->to('#operations')->attach([
	'fallback' => 'It is all broken, man',
	'text' => 'It is _all_ broken, man',
	'pretext' => 'From user: *JimBob*',
	'color' => 'danger',
	'mrkdwn_in' => ['pretext', 'text']
])->send('New alert from the monitoring system');
```

#### Explicit message creation

[](#explicit-message-creation)

For convenience, message objects are created implicitly by calling message methods on the client. We can however do this explicitly to avoid hitting the magic method.

```
// Implicitly
$client->to('@jeremykenedy')->send('I am sending this implicitly');

// Explicitly
$message = $client->createMessage();

$message->to('@jeremykenedy')->setText('I am sending this explicitly');

$message->send();
```

#### Attachments

[](#attachments)

When using attachments, the easiest way is to provide an array of data as shown in the examples, which is actually converted to an Attachment object under the hood. You can also attach an Attachment object to the message:

```
$attachment = new Attachment([
	'fallback' => 'Some fallback text',
	'text' => 'The attachment text'
]);

// Explicitly create a message from the client
// rather than using the magic passthrough methods
$message = $client->createMessage();

$message->attach($attachment);

// Explicitly set the message text rather than
// implicitly through the send method
$message->setText('Hello world')->send();
```

Each attachment field is also an object, an AttachmentField. They can be used as well instead of their data in array form:

```
$attachment = new Attachment([
	'fallback' => 'Some fallback text',
	'text' => 'The attachment text',
	'fields' => [
		new AttachmentField([
			'title' => 'A title',
			'value' => 'A value',
			'short' => true
		])
	]
]);
```

You can also set the attachments and fields directly if you have a whole lot of them:

```
// implicitly create a message and set the attachments
$client->setAttachments($bigArrayOfAttachments);

// or explicitly
$client->createMessage()->setAttachments($bigArrayOfAttachments);
```

```
$attachment = new Attachment([]);

$attachment->setFields($bigArrayOfFields);
```

### Contributing

[](#contributing)

If you're having problems, spot a bug, or have a feature suggestion, please log and issue on Github. If you'd like to have a crack yourself, fork the package and make a pull request. Please include tests for any added or changed functionality. If it's a bug, include a regression test.

### Credits

[](#credits)

- Full development credit must go to [maknz](https://github.com/maknz/slack).
- This package was forked and improved. The original package states that it was no longer maintained.
- This package was forked and modified to be compliant with [MIT](https://opensource.org/licenses/MIT) licencing standards for production use.

### License

[](#license)

Slack for PHP is licensed under the MIT license for both personal and commercial products. Enjoy!

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity44

Moderate usage in the ecosystem

Community13

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 93.3% 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 ~416 days

Total

4

Last Release

1974d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/05cef7d9ee65723b129042943511207fb34db74a56afbf67b5900987f758c161?d=identicon)[jeremykenedy](/maintainers/jeremykenedy)

---

Top Contributors

[![jeremykenedy](https://avatars.githubusercontent.com/u/6244570?v=4)](https://github.com/jeremykenedy "jeremykenedy (14 commits)")[![jasonmccreary](https://avatars.githubusercontent.com/u/161071?v=4)](https://github.com/jasonmccreary "jasonmccreary (1 commits)")

---

Tags

laravelslack

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[maknz/slack

A simple PHP package for sending messages to Slack, with a focus on ease of use and elegant syntax.

1.2k11.7M65](/packages/maknz-slack)[guanguans/notify

Push notification SDK(AnPush、Bark、Chanify、DingTalk、Discord、Gitter、GoogleChat、IGot、Lark、Mattermost、MicrosoftTeams、NowPush、Ntfy、Push、Pushback、PushBullet、PushDeer、PushMe、Pushover、PushPlus、QQ、RocketChat、ServerChan、ShowdocPush、SimplePush、Slack、Telegram、WeWork、WPush、XiZhi、YiFengChuanHua、ZohoCliq、ZohoCliqWebHook、Zulip).

682104.9k7](/packages/guanguans-notify)[beyondcode/slack-notification-channel

Slack Notification Channel for Laravel using API tokens.

85525.8k](/packages/beyondcode-slack-notification-channel)[tzsk/sms

A robust and unified SMS gateway integration package for Laravel, supporting multiple providers.

320244.3k6](/packages/tzsk-sms)[erag/laravel-disposable-email

A Laravel package to detect and block disposable email addresses.

226102.4k](/packages/erag-laravel-disposable-email)[razorpay/slack

A simple PHP package for sending messages to Slack, with a focus on ease of use and elegant syntax.

20414.5k3](/packages/razorpay-slack)

PHPackages © 2026

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