This package is abandoned and no longer maintained. No replacement package was suggested.

Simple client to send notifications through Slack webhooks.

0.1.0 2020-06-01 19:46 UTC

This package is auto-updated.

Last update: 2022-03-07 20:57:35 UTC


README

68747470733a2f2f757074696d6570726f6a6563742e696f2f696d672f6c6f676f2e706e67

Codecov GitHub Workflow Status Packagist PHP Version Support Packagist PHP Version Support Packagist Downloads

A minimal but flexible integration for slack webhooks.

How to use

<?php

use UptimeProject\Slack\Workspace;

$workspace = new Workspace('https://hooks.slack.com/services/blablabla');
$workspace->from('John')->send('Hello!');

Adding profile icons

If no icon is given, the default icon for the integration is used.

<?php

use UptimeProject\Slack\Workspace;

$workspace = new Workspace('https://hooks.slack.com/services/blablabla');
// You can use an icon as avatar
$workspace->from('John', ':tophat:')->send('Hello!');

// Or an image from the web
$imgUrl = 'https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png';
$workspace->from('John', $imgUrl)->send('Hello!');

68747470733a2f2f692e696d6775722e636f6d2f5172763342796b2e706e67

Specifying a channel

If no channel name is given, the default channel for the webhook is used.

<?php

use UptimeProject\Slack\Workspace;

$workspace = new Workspace('https://hooks.slack.com/services/blablabla');

// Send message to a specific channel
$workspace->from('John')->send('Hello!', '#general');

How to contribute

Feel free to create a PR if you have any ideas for improvements. Or create an issue.

  • When adding code, make sure to add tests for it (phpunit).
  • Make sure the code adheres to our coding standards (use php-cs-fixer to check/fix).
  • Also make sure PHPStan does not find any bugs.
vendor/bin/php-cs-fixer fix

vendor/bin/phpstan analyze

vendor/bin/phpunit --coverage-text

These tools will also run in Github Actions on PR's and pushes on master.