PHPackages                             elfsundae/bearychat - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. elfsundae/bearychat

AbandonedArchivedLibrary[HTTP &amp; Networking](/categories/http)

elfsundae/bearychat
===================

An elegant way of interacting with BearyChat webhooks.

1.3.1(8y ago)6643.1k132MITPHPPHP &gt;=5.4.0

Since Jul 1Pushed 6y ago1 watchersCompare

[ Source](https://github.com/ElfSundae/bearychat)[ Packagist](https://packagist.org/packages/elfsundae/bearychat)[ Docs](https://github.com/ElfSundae/bearychat)[ RSS](/packages/elfsundae-bearychat/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (3)Versions (20)Used By (2)

BearyChat for PHP
=================

[](#bearychat-for-php)

[![Latest Version on Packagist](https://camo.githubusercontent.com/4df496fa043ab9866d77d80718f04f5e0af50748f377c110b3ddcc8e8a0368fd/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f656c6673756e6461652f6265617279636861742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/elfsundae/bearychat)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/9f8ad76bd08de1bd19a1689beec8edca2371548ab4e309b809266f4d95829fe9/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f456c6653756e6461652f6265617279636861742f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/ElfSundae/bearychat)[![StyleCI](https://camo.githubusercontent.com/1e262a875d52a8c056d8eecf1fbe5dcd95692fb472bdbc434d5c07d7b6d7deb6/68747470733a2f2f7374796c6563692e696f2f7265706f732f36323338393939352f736869656c64)](https://styleci.io/repos/62389995)[![SensioLabsInsight](https://camo.githubusercontent.com/44a6218633ab61c90b842ac67215d103224d87c7d3a9e61be96a79fb9bc8882e/68747470733a2f2f696d672e736869656c64732e696f2f73656e73696f6c6162732f692f38333066383437352d393562312d343335332d613865312d6431396131613365313662332e7376673f7374796c653d666c61742d737175617265)](https://insight.sensiolabs.com/projects/830f8475-95b1-4353-a8e1-d19a1a3e16b3)[![Quality Score](https://camo.githubusercontent.com/72fe5357b3b4a71f6cd33cb4e320f5e41b27068e47334c92cfba711ac50df7f1/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f456c6653756e6461652f6265617279636861742e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/ElfSundae/bearychat)[![Code Coverage](https://camo.githubusercontent.com/dbf235bb3b3de912eb0aadddf6c3067f6b21a17f5929e274b0d05566e28105b0/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f456c6653756e6461652f6265617279636861742f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/ElfSundae/bearychat/?branch=master)[![Total Downloads](https://camo.githubusercontent.com/c9b4a2665f665b02968ba33bf747c8c2ded91bac9d72d1f62b5ae2bcf003910d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f656c6673756e6461652f6265617279636861742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/elfsundae/bearychat)

A PHP package for sending message to [BearyChat](https://bearychat.com) with the [Incoming Webhook](https://bearychat.com/integrations/incoming), and creating response payload for the [Outgoing Robot](https://bearychat.com/integrations/outgoing).

- 🇨🇳 [**中文文档**](README_zh.md)
- **Laravel integration:** [BearyChat for Laravel](https://github.com/ElfSundae/laravel-bearychat)
- **Laravel Notification Channel:** [BearyChatChannel](https://github.com/laravel-notification-channels/bearychat)
- **Yii integration:** [BearyChat for Yii 2](https://github.com/krissss/yii2-beary-chart)

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

[](#installation)

You can install this package using the [Composer](https://getcomposer.org) manager.

```
composer require elfsundae/bearychat

```

Then you may create an Incoming Robot on your [BearyChat](https://bearychat.com) team account, and read the [payload format](https://bearychat.com/integrations/incoming).

Documentation
-------------

[](#documentation)

### Overview

[](#overview)

```
(new Client('https://hook.bearychat.com/=...'))
    ->text('content')
    ->add('attachment', 'title')
    ->addImage($imageUrl, 'image description')
    ->sendTo('admin');

(new Client($webhook))->send('content', 'attachment');
```

To send messages, first create a [BearyChat client](src/Client.php) with your webhook URL:

```
$client = new ElfSundae\BearyChat\Client('http://hook.bearychat.com/=.../incoming/...');
```

Besides the webhook, you may want to setup some default values for all messages which will be sent with this client:

```
use ElfSundae\BearyChat\Client;

$client = new Client($webhook, [
    'channel' => 'server-log',
    'attachment_color' => '#3e4787'
]);
```

All defaults keys are listed in [`MessageDefaults`](src/MessageDefaults.php) . You can access message default with `$client->getMessageDefaults($key)`, or retrieve all defaults with `$client->getMessageDefaults()` .

To send a message, just call `sendMessage` on the client instance with a [message payload](https://bearychat.com/integrations/incoming) array or a payload JSON string:

```
$client->sendMessage([
    'text' => 'Hi, Elf!',
    'user' => 'elf'
]);

$json = '{"text": "Good job :+1:", "channel": "all"}';
$client->sendMessage($json);
```

In addition to the ugly payload, `sendMessage` can handle any `JsonSerializable` instances or any object which provides a payload via its `toArray` or `toJson` method. And there is a ready-made [`Message`](src/Message.php) class available for creating payloads for Incoming messages or Outgoing responses. There are a variety of convenient methods that can work with the payload in [`Message`](src/Message.php) class.

For convenience, any unhandled methods called to a `Client` instance will be sent to a new `Message` instance, and the most methods of a `Message` instance return itself, so you can chain [message modifications](#message-modifications) to achieve one-liner code.

You can also call the powerful `send` or `sendTo` method with message contents for [sending a message](#sending-message).

```
$client->to('#all')->text('Hello')->add('World')->send();

$client->sendTo('all', 'Hello', 'World');
```

### Message Modifications

[](#message-modifications)

Available methods for message modification in the `Message` class:

- **text**: `getText` , `setText($text)` , `text($text)`
- **notification**: `getNotification` , `setNotification($notification)` , `notification($notification)`
- **markdown**: `getMarkdown` , `setMarkdown($markdown)` , `markdown($markdown = true)`
- **channel**: `getChannel` , `setChannel($channel)` , `channel($channel)` , `to($channel)`
- **user**: `getUser` , `setUser($user)` , `user($user)` , `to('@'.$user)`
- **target** (user or channel): `getTarget`, `setTarget($target)`, `target($target)`, `removeTarget`, `to($target)`
- **attachments**: `getAttachments` , `setAttachments($attachments)` , `attachments($attachments)` , `addAttachment(...)` , `add(...)` , `addImage` , `removeAttachments(...)` , `remove(...)`
- `content($text, $markdown, $notification)`, `content($text, $attachment_text, $attachment_title, $attachment_images, $attachment_color)`

As you can see, the `to($target)` method can change the message's target to an user if `$target` is started with `@` , otherwise it will set the channel that the message should be sent to. The channel's starter mark `#` is **optional** in `to` method, which means the result of `to('#dev')` and `to('dev')` is the same.

Method `addAttachment($attachment)` accepts a PHP array of attachment payload, or a variable arguments list in order of `text, title, images, color`, and the `images` can be an image URL or an array contains image URLs. And this type of attachment parameters is also applicable to the method `add`.

```
$client
    ->to('@elf')
    ->text('message')
    ->add([
        'text' => 'Content of the first attachment.',
        'title' => 'First Attachment',
        'images' => [$imageUrl, $imageUrl2],
        'color' => '#10e4fe'
    ])
    ->add(
        'Content of the second attachment.',
        'Second Attachment',
        [$imageUrl, $imageUrl2],
        'red'
    )
    ->send();
```

To remove attachments, call `removeAttachments` or `remove` with indices.

```
$message->remove(0)->remove(0, 1)->remove([1, 3])->remove();
```

### Message Representation

[](#message-representation)

Call the `toArray()` method on a Message instance will get the payload array for this message. You may use `$message->toJson()`, `json_encode($message)` or `(string) $message` to get the JSON payload for `$message`.

> ⚠️ **The message payload may be used for requesting an [Incoming Webhook](https://bearychat.com/integrations/incoming) or creating response for an [Outgoing Robot](https://bearychat.com/integrations/outgoing).**

```
$message = $client->to('@elf')->text('foo')->markdown(false)
    ->add('bar', 'some images', 'path/to/image', 'blue');

echo $message->toJson(JSON_PRETTY_PRINT);
```

The above example will output:

```
{
    "text": "foo",
    "markdown": false,
    "user": "elf",
    "attachments": [
        {
            "text": "bar",
            "title": "some images",
            "images": [
                {
                    "url": "path\/to\/image"
                }
            ],
            "color": "blue"
        }
    ]
}
```

### Sending Message

[](#sending-message)

You can call `send` or `sendTo` method on a Message instance to send that message.

The `send` method optional accepts variable number of arguments to quickly change the payload content:

- Sending a basic message: `send($text, $markdown = true, $notification)`
- Sending a message with one attachment added: `send($text, $attachment_text, $attachment_title, $attachment_images, $attachment_color)`

The `sendTo` method is useful when you want to change the message's target before calling `send` method.

```
$client = new Client($webhook, [
    'channel' => 'all'
]);

// Sending a message to the default channel
$client->send('Hi there :smile:');

// Sending a customized message
$client->send('disable **markdown**', false, 'custom notification');

// Sending a message with one attachment added
$client->send('message title', 'Attachment Content');

// Sending a message with an customized attachment
$client->send(
    'message with an customized attachment',
    'Attachment Content',
    'Attachment Title',
    $imageUrl,
    '#f00'
);

// Sending a message with multiple images
$client->send('multiple images', null, null, [$imageUrl1, $imageUrl2]);

// Sending a message to a different channel
$client->sendTo('iOS', '**Lunch Time !!!**');

// Sending a message to an user
$client->sendTo('@elf', 'Where are you?');
```

### Customize Client

[](#customize-client)

If you want to create a `Message` instance explicitly, the client's `createMessage` method will return a fresh `Message` instance configured with the client's message defaults.

A `Client` instance is mutable, it means you can change its webhook URL or the message defaults by calling `setWebhook`, `webhook` or `setMessageDefaults`.

```
$client->webhook($webhook_ios)->setMessageDefaults([
    'channel' => 'ios_dev'
])->send('App reviewing status has updated.');
```

Testing
-------

[](#testing)

```
$ composer test
```

License
-------

[](#license)

The BearyChat PHP package is available under the [MIT license](LICENSE).

###  Health Score

39

—

LowBetter than 84% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity38

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

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

###  Release Activity

Cadence

Every ~23 days

Recently: every ~93 days

Total

19

Last Release

3226d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/526008?v=4)[Elf Sundae](/maintainers/ElfSundae)[@ElfSundae](https://github.com/ElfSundae)

---

Top Contributors

[![ElfSundae](https://avatars.githubusercontent.com/u/526008?v=4)](https://github.com/ElfSundae "ElfSundae (173 commits)")

---

Tags

bearychatphprobotwebhookwebhookrobotincomingoutgoingbearychat

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/elfsundae-bearychat/health.svg)

```
[![Health](https://phpackages.com/badges/elfsundae-bearychat/health.svg)](https://phpackages.com/packages/elfsundae-bearychat)
```

###  Alternatives

[aws/aws-sdk-php

AWS SDK for PHP - Use Amazon Web Services in your PHP project

6.3k543.5M2.6k](/packages/aws-aws-sdk-php)[neuron-core/neuron-ai

The PHP Agentic Framework.

2.0k656.1k39](/packages/neuron-core-neuron-ai)[illuminate/http

The Illuminate Http package.

11937.9M7.0k](/packages/illuminate-http)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3741.3M46](/packages/tencentcloud-tencentcloud-sdk-php)[shopify/shopify-api

Shopify API Library for PHP

4655.4M23](/packages/shopify-shopify-api)[eslazarev/wildberries-sdk

Wildberries OpenAPI clients (generated).

273.0k](/packages/eslazarev-wildberries-sdk)

PHPackages © 2026

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