PHPackages                             valerijv/php-slack-bot-vpatch - 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. valerijv/php-slack-bot-vpatch

ActiveLibrary

valerijv/php-slack-bot-vpatch
=============================

Slack bot user written in PHP

12PHP

Since May 11Pushed 10y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

PHP Slack Bot
=============

[](#php-slack-bot)

A simple bot user written in PHP using the Slack Real Time Messaging API

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

[](#installation)

With Composer

Create a new composer.json file and add the following

```
{
    "minimum-stability" : "dev",
    "require": {
        "valerijv/php-slack-bot-vpatch": "dev-master"
    }
}

```

Then run

```
composer install

```

Usage
-----

[](#usage)

```
require 'vendor/autoload.php';
use PhpSlackBot\Bot;

// Custom command
class MyCommand extends \PhpSlackBot\Command\BaseCommand {

    protected function configure() {
        $this->setName('mycommand');
    }

    protected function execute($message, $context) {
        $this->send($this->getCurrentChannel(), null, 'Hello !');
    }

}

$bot = new Bot();
$bot->setToken('TOKEN'); // Get your token here https://my.slack.com/services/new/bot
$bot->loadCommand(new MyCommand());
$bot->run();
```

Example commands
----------------

[](#example-commands)

Example commands are located in `src/PhpSlackBot/Command/`

##### Ping Pong Command

[](#ping-pong-command)

Type `ping` in a channel and the bot should answer "Pong" to you.

##### Count Command

[](#count-command)

Type `count` several times in a channel and the bot should answer with 1 then 2...

##### Date Command

[](#date-command)

Type `date` in a channel and the current date.

##### Planning Poker Command

[](#planning-poker-command)

[https://en.wikipedia.org/wiki/Planning\_poker](https://en.wikipedia.org/wiki/Planning_poker)

Type `pokerp start` in a public channel with your team in order to start a planning poker session.

Direct message the bot with `pokerp vote number`. The bot will record your vote.

Type `pokerp status` to see the current status of the session (who has voted).

Type `pokerp end` in a public channel and the bot will output each vote.

Load your own commands
----------------------

[](#load-your-own-commands)

You can load your own commands by implementing the \\PhpSlackBot\\Command\\BaseCommand.

Then call PhpSlackBot\\Bot::loadCommand method for each command you have to load.

"Catch All" command
-------------------

[](#catch-all-command)

If you need to execute a command when an event occurs, you can set up a "catch all" command.

This special command will be triggered on all events and all other commands will be ignored.

```
require 'vendor/autoload.php';
use PhpSlackBot\Bot;

// This special command executes on all events
class SuperCommand extends \PhpSlackBot\Command\BaseCommand {

    protected function configure() {
        // We don't have to configure a command name in this case
    }

    protected function execute($data, $context) {
        if ($data['type'] == 'message') {
            $channel = $this->getChannelNameFromChannelId($data['channel']);
            $username = $this->getUserNameFromUserId($data['user']);
            echo $username.' from '.($channel ? $channel : 'DIRECT MESSAGE').' : '.$data['text'].PHP_EOL;
        }
    }

}

$bot = new Bot();
$bot->setToken('TOKEN'); // Get your token here https://my.slack.com/services/new/bot
$bot->loadCatchAllCommand(new SuperCommand());
$bot->run();
```

Incoming webhooks
-----------------

[](#incoming-webhooks)

The bot can also listen for incoming webhooks.

Commands are triggered from users messages inside Slack and webhooks are triggered from web post requests.

Custom webhooks can be loaded using the PhpSlackBot\\Bot::loadWebhook method.

This is useful if you need to control the bot from an external service. For example, with IFTTT

To enable webhooks, use the enableWebserver method before the run method.

You can also set a secret token to prevent unauthorized requests.

```
$bot->enableWebserver(8080, 'secret'); // This will listen on port 8080
$bot->run();
```

Then, use the parameter "name" to trigger the corresponding webhook :

```
curl -X POST --data-urlencode 'auth=secret' --data-urlencode 'name=output' --data-urlencode 'payload={"type" : "message", "text": "This is a message", "channel": "#general"}' http://localhost:8080

```

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 89.7% 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.

### Community

Maintainers

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

---

Top Contributors

[![jclg](https://avatars.githubusercontent.com/u/645802?v=4)](https://github.com/jclg "jclg (35 commits)")[![valerijv](https://avatars.githubusercontent.com/u/6775108?v=4)](https://github.com/valerijv "valerijv (4 commits)")

### Embed Badge

![Health badge](/badges/valerijv-php-slack-bot-vpatch/health.svg)

```
[![Health](https://phpackages.com/badges/valerijv-php-slack-bot-vpatch/health.svg)](https://phpackages.com/packages/valerijv-php-slack-bot-vpatch)
```

PHPackages © 2026

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