Slack

alek13/slack image

Slack stats

Downloads
1.9M
Stars
131
Open Issues
0
Forks
26

View on GitHub →

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

Slack for PHP

Slack for PHP is a streamlined package that allows PHP developers to easily send messages to Slack using incoming webhooks. This package, a fork of the previously popular but abandoned maknz/slack, prides itself on its simplicity and elegant PHP syntax.

Features

  • Easy Installation: Quickly integrate with Composer.
  • Configurable: Set defaults like username, channel, and icons or adjust on a per-message basis.
  • Robust Messaging Options: Send messages directly to channels or users, with options for different usernames, icons, and visibility.
  • Attachments and Formatting: Supports rich content including attachments with fields, author details, and Slack's Block Kit for interactive messages.
  • Markdown Support: Enable or disable Markdown parsing in messages and attachments.
  • Advanced Usage: Directly manipulate message objects and attachment fields for complex scenarios.

Installation

  1. Create an incoming webhook on your Slack workspace.
  2. Install via Composer:
    composer require alek13/slack

Usage

Basic Usage

Instantiate the client and send messages:

use Maknz\Slack\Client;
 
$client = new Client('https://hooks.slack.com/services/...');
$client->to('#general')->send('Good morning');

Advanced Messaging

  • Customize appearance and responses: Change default settings like username or icon, and control message visibility.
  • Attachments: Enhance messages with detailed attachments, specifying colors, pretext, author details, and more.
  • Interactive Messages: Utilize Slack's Block Kit to add interactive elements like buttons to messages.

Practical Examples

// Sending a message with custom username and icon
$client->from('Jake the Dog')->to('@FinnTheHuman')->send('Adventure time!');
 
// Sending an interactive message using Block Kit
$client->to('@regan')->withBlock([
'type' => 'section',
'text' => 'Do you love the app?'
])->send('Notification fallback message');

Playground

Explore message formatting and features using the php-slack/playground script.

Support and Contribution

Join the Slack community if you need help, want to contribute, or simply connect with other users. Contributions via GitHub pull requests are welcome, please include tests for new or updated functionality.

For more details on using or contributing to the package, visit the GitHub repository.

php-slack photo

Founder of @PhpProfi. Maintainer at @php-slack & @PHPColibri . Love @minetest. Lead @lord-server . Born on the 13th.

Cube

Laravel Newsletter

Join 40k+ other developers and never miss out on new tips, tutorials, and more.


Alek13 Slack Related Articles

Monitor Laravel Queues, Commands, and Schedulers on Any Driver with Vigilance image

Monitor Laravel Queues, Commands, and Schedulers on Any Driver with Vigilance

Read article
LaraOwl: Self-Hosted Monitoring for Laravel Applications image

LaraOwl: Self-Hosted Monitoring for Laravel Applications

Read article
Chevere Workflow: A Declarative PHP Workflow Engine with Async Job Execution image

Chevere Workflow: A Declarative PHP Workflow Engine with Async Job Execution

Read article
Laravel Web Push Notifications image

Laravel Web Push Notifications

Read article
Debugging production Laravel apps without losing your mind image

Debugging production Laravel apps without losing your mind

Read article
Axios npm Package Compromised With Remote Access Trojan image

Axios npm Package Compromised With Remote Access Trojan

Read article
Kirschbaum logo

Kirschbaum

Providing innovation and stability to ensure your web application succeeds.

Kirschbaum
Honeybadger logo

Honeybadger

Simple developer-focused application monitoring for Laravel. Error tracking, log management, uptime monitoring, status pages, and more!

Honeybadger
Shift logo

Shift

Running an old Laravel version? Instant, automated Laravel upgrades and code modernization to keep your applications fresh.

Shift
Securing Laravel logo

Securing Laravel

The essential security resource for Laravel devs, covering everything you need to keep your apps secure. Sign up to receive weekly security tips and monthly in depth articles, diving deep into security concepts you need to know!

Securing Laravel
Acquaint Softtech logo

Acquaint Softtech

Acquaint Softtech offers AI-ready Laravel developers who onboard in 48 hours at $3000/Month with no lengthy sales process and a 100 percent money-back guarantee.

Acquaint Softtech
Lucky Media logo

Lucky Media

Get Lucky Now - the ideal choice for Laravel Development, with over a decade of experience!

Lucky Media