PHPackages                             miljan9602/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. miljan9602/slack

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

miljan9602/slack
================

A simple PHP package (fork of maknz/slack) for sending messages to Slack, with a focus on ease of use and elegant syntax.

0.0.3(7y ago)02541BSD-2-ClausePHPPHP ^7.0

Since May 10Pushed 7y ago1 watchersCompare

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

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

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

[](#slack-for-php)

[![Build Status](https://camo.githubusercontent.com/0f2c8f587c95cbb26be52433965f96ab3e0a33998b5d1a251189fd68e6123007/68747470733a2f2f7472617669732d63692e6f72672f7068702d736c61636b2f736c61636b2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/php-slack/slack)[![Code Coverage](https://camo.githubusercontent.com/56f889c2026ea96c46b3bf1174e6a9c8627444dc0a8f46fea0bb6773a76cf8c5/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f616c656b31332f736c61636b2f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/alek13/slack/?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/2387e72967df0f4d68d0c98d72d01fb4bc2037272d931f8051f94fc45e093baa/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f616c656b31332f736c61636b2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/alek13/slack/?branch=master)[![Dependency Status](https://camo.githubusercontent.com/062ac8875d394fca61fa032470559cf98f35be7279e78f2dcf6a85a8a5d899f4/68747470733a2f2f626574612e67656d6e617369756d2e636f6d2f6261646765732f6769746875622e636f6d2f616c656b31332f736c61636b2e737667)](https://beta.gemnasium.com/projects/github.com/alek13/slack)[![StyleCI](https://camo.githubusercontent.com/afbfd2cc293d22e5c955e41cac717ae63615b3265c89e3335cde3716a5e897d1/68747470733a2f2f7374796c6563692e696f2f7265706f732f3131363439373830302f736869656c64)](https://styleci.io/repos/116497800) | [![Slack Welcome](https://camo.githubusercontent.com/35317c88c9780a88a997058cee9afca17e137a4120e2e1b414780c8eb14c0670/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f736c61636b2d77656c636f6d652d627269676874677265656e2e737667)](https://join.slack.com/t/php-slack/shared_invite/enQtMjk1OTExNDkzMjg1LTk5ODg3MGE1OThlYzZlM2U0N2I5Y2FhM2NiYmFlMjE1MDNiOWRjMjc1ZDIwNWZlNzBkZWQ2ZWM1NzdmMjM5YzQ)

A simple PHP package for sending messages to [Slack](https://slack.com)with [incoming webhooks](https://my.slack.com/services/new/incoming-webhook), focused on ease-of-use and elegant syntax.

**supports:** PHP `7.0`, `7.1`, `7.2`
**require:** `guzzlehttp/guzzle` any of versions `~6.0|~5.0|~4.0`

> This is the fork of popular, great, but abandoned package [`maknz/slack`](https://github.com/maknz/slack)

Quick Tour
==========

[](#quick-tour)

- `composer require alek13/slack`
- [create an incoming webhook](https://my.slack.com/services/new/incoming-webhook) &amp; copy `hook_url`
- `$client = new Client('http://hook_url')`
- `$client->to('#general')->send('Good morning');`

Done!

---

---

---

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

[](#installation)

You can install the package using the [Composer](https://getcomposer.org/) package manager by running in your project root:

```
composer require alek13/slack
```

Incoming WebHook
----------------

[](#incoming-webhook)

Then [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 Maknz\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 @regan or #channel will also be linked.
$settings = [
	'username' => 'Cyril',
	'channel' => '#accounting',
	'link_names' => true
];

$client = new Maknz\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 `@regan` 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 ([preview](https://goo.gl/fY43nw))

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

```
$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('@regan')->send('Yo!');
```

#### Sending a message to a channel as a different bot name ([preview](https://goo.gl/xCeEfY))

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

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

#### Sending a message with a different icon ([preview](https://goo.gl/lff21l))

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

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

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

#### Send an attachment ([preview](https://goo.gl/fp3iaY))

[](#send-an-attachment-preview)

```
$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 ([preview](https://goo.gl/264mhU))

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

```
$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 ([preview](https://goo.gl/CKd1zJ))

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

```
$client->to('@regan')->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('@regan')->send('I am sending this implicitly');

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

$message->to('@regan')->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);
```

Playground
==========

[](#playground)

There is the [`php-slack/playground`](https://github.com/php-slack/playground) simple console script to test messaging and to see how messages looks really.

Questions
=========

[](#questions)

[![Slack Welcome](https://camo.githubusercontent.com/35317c88c9780a88a997058cee9afca17e137a4120e2e1b414780c8eb14c0670/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f736c61636b2d77656c636f6d652d627269676874677265656e2e737667)](https://join.slack.com/t/php-slack/shared_invite/enQtMjk1OTExNDkzMjg1LTk5ODg3MGE1OThlYzZlM2U0N2I5Y2FhM2NiYmFlMjE1MDNiOWRjMjc1ZDIwNWZlNzBkZWQ2ZWM1NzdmMjM5YzQ)

If you have any questions how to use or contribute,
you are welcome in our [Slack Workspace](https://join.slack.com/t/php-slack/shared_invite/enQtMjk1OTExNDkzMjg1LTk5ODg3MGE1OThlYzZlM2U0N2I5Y2FhM2NiYmFlMjE1MDNiOWRjMjc1ZDIwNWZlNzBkZWQ2ZWM1NzdmMjM5YzQ).

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

[](#contributing)

[![Slack Welcome](https://camo.githubusercontent.com/35317c88c9780a88a997058cee9afca17e137a4120e2e1b414780c8eb14c0670/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f736c61636b2d77656c636f6d652d627269676874677265656e2e737667)](https://join.slack.com/t/php-slack/shared_invite/enQtMjk1OTExNDkzMjg1LTk5ODg3MGE1OThlYzZlM2U0N2I5Y2FhM2NiYmFlMjE1MDNiOWRjMjc1ZDIwNWZlNzBkZWQ2ZWM1NzdmMjM5YzQ)

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.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community20

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~169 days

Total

3

Last Release

2584d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/fd248f5852907c572575507ff617416e5439bfcc481bd981406919615887539c?d=identicon)[Miljan9602](/maintainers/Miljan9602)

---

Top Contributors

[![maknz](https://avatars.githubusercontent.com/u/992356?v=4)](https://github.com/maknz "maknz (77 commits)")[![alek13](https://avatars.githubusercontent.com/u/1972329?v=4)](https://github.com/alek13 "alek13 (72 commits)")[![nikolac92](https://avatars.githubusercontent.com/u/23655589?v=4)](https://github.com/nikolac92 "nikolac92 (8 commits)")[![vysinsky](https://avatars.githubusercontent.com/u/3693578?v=4)](https://github.com/vysinsky "vysinsky (2 commits)")[![freekmurze](https://avatars.githubusercontent.com/u/483853?v=4)](https://github.com/freekmurze "freekmurze (2 commits)")[![georgecoca](https://avatars.githubusercontent.com/u/6689915?v=4)](https://github.com/georgecoca "georgecoca (2 commits)")[![mvatansever](https://avatars.githubusercontent.com/u/5843891?v=4)](https://github.com/mvatansever "mvatansever (2 commits)")[![rdfirtal](https://avatars.githubusercontent.com/u/95298049?v=4)](https://github.com/rdfirtal "rdfirtal (2 commits)")[![Miljan9602](https://avatars.githubusercontent.com/u/19391119?v=4)](https://github.com/Miljan9602 "Miljan9602 (1 commits)")[![tzookb](https://avatars.githubusercontent.com/u/3749973?v=4)](https://github.com/tzookb "tzookb (1 commits)")[![drewbroadley](https://avatars.githubusercontent.com/u/1505816?v=4)](https://github.com/drewbroadley "drewbroadley (1 commits)")[![qmcree](https://avatars.githubusercontent.com/u/7796024?v=4)](https://github.com/qmcree "qmcree (1 commits)")[![rajabishek](https://avatars.githubusercontent.com/u/6145125?v=4)](https://github.com/rajabishek "rajabishek (1 commits)")[![rap2hpoutre](https://avatars.githubusercontent.com/u/1575946?v=4)](https://github.com/rap2hpoutre "rap2hpoutre (1 commits)")[![Anahkiasen](https://avatars.githubusercontent.com/u/1321596?v=4)](https://github.com/Anahkiasen "Anahkiasen (1 commits)")[![stefanzweifel](https://avatars.githubusercontent.com/u/1080923?v=4)](https://github.com/stefanzweifel "stefanzweifel (1 commits)")[![jwcobb](https://avatars.githubusercontent.com/u/777522?v=4)](https://github.com/jwcobb "jwcobb (1 commits)")[![iwiznia](https://avatars.githubusercontent.com/u/521248?v=4)](https://github.com/iwiznia "iwiznia (1 commits)")

---

Tags

laravelslack

###  Code Quality

TestsPHPUnit

### Embed Badge

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

```
[![Health](https://phpackages.com/badges/miljan9602-slack/health.svg)](https://phpackages.com/packages/miljan9602-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)
