Polyscope - The agent-first dev environment for Laravel

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.


Alek13 Slack Related Articles

Advanced Application Architecture through Laravel's Service Container Management image

Advanced Application Architecture through Laravel's Service Container Management

Read article
Laravel's Rule::contains() for Fluent Array Validation image

Laravel's Rule::contains() for Fluent Array Validation

Read article
Come for the Simplicity, Stay for the Extensibility: Identity with FusionAuth image

Come for the Simplicity, Stay for the Extensibility: Identity with FusionAuth

Read article
Fusion Developer Preview is released: Write PHP inside your Vue and React components image

Fusion Developer Preview is released: Write PHP inside your Vue and React components

Read article
Log Alarm Package for Laravel image

Log Alarm Package for Laravel

Read article
Rule::array() and whereJsonOverlaps() for MySQL in Laravel 11.7 image

Rule::array() and whereJsonOverlaps() for MySQL in Laravel 11.7

Read article
Lucky Media logo

Lucky Media

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

Lucky Media
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
Kirschbaum logo

Kirschbaum

Providing innovation and stability to ensure your web application succeeds.

Kirschbaum
Shift logo

Shift

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

Shift
Laravel Cloud logo

Laravel Cloud

Easily create and manage your servers and deploy your Laravel applications in seconds.

Laravel Cloud
Harpoon: Next generation time tracking and invoicing logo

Harpoon: Next generation time tracking and invoicing

The next generation time-tracking and billing software that helps your agency plan and forecast a profitable future.

Harpoon: Next generation time tracking and invoicing