PHPackages                             gnello/php-mattermost-driver - 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. gnello/php-mattermost-driver

ActiveLibrary

gnello/php-mattermost-driver
============================

The Php Driver to interact with the Mattermost Web Service API

v2.19.2(1y ago)84304.8k↓10.4%31[4 PRs](https://github.com/gnello/php-mattermost-driver/pulls)4MITPHPPHP &gt;=5.5.0

Since Apr 19Pushed 1y ago3 watchersCompare

[ Source](https://github.com/gnello/php-mattermost-driver)[ Packagist](https://packagist.org/packages/gnello/php-mattermost-driver)[ Docs](https://github.com/gnello/php-mattermost-driver)[ RSS](/packages/gnello-php-mattermost-driver/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)Dependencies (4)Versions (38)Used By (4)

php-mattermost-driver
=====================

[](#php-mattermost-driver)

[![Latest Stable Version](https://camo.githubusercontent.com/a51a9114bc6dd8685ebb2dd1deb28ebaaa325233d250d2dd12dc424032af9ca9/68747470733a2f2f706f7365722e707567782e6f72672f676e656c6c6f2f7068702d6d61747465726d6f73742d6472697665722f762f737461626c65)](https://packagist.org/packages/gnello/php-mattermost-driver) [![Scrutinizer Code Quality](https://camo.githubusercontent.com/093a516c2fb9d6fa475da8206c42c78223d4bef01962a8f060cfe1b1b933a5b2/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f676e656c6c6f2f7068702d6d61747465726d6f73742d6472697665722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/gnello/php-mattermost-driver/?branch=master) [![Total Downloads](https://camo.githubusercontent.com/e56d41645a67d36ec84937dc715ac6c01e30a545962a3af0a8448b74ebcb534e/68747470733a2f2f706f7365722e707567782e6f72672f676e656c6c6f2f7068702d6d61747465726d6f73742d6472697665722f646f776e6c6f616473)](https://packagist.org/packages/gnello/php-mattermost-driver)

The PHP Driver to interact with the [Mattermost Web Service API](https://about.mattermost.com/).

Please read [the api documentation](https://api.mattermost.com/) for further information on using this application.

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

[](#installation)

### Composer

[](#composer)

The best way to install php-mattermost-driver is to use Composer:

```
composer require gnello/php-mattermost-driver

```

Read more about how to install and use Composer on your local machine [here](https://getcomposer.org/doc/00-intro.md#installation-linux-unix-osx).

### Laravel

[](#laravel)

If you are going to install this library on laravel maybe you prefer to install the [laravel-mattermost-driver](https://github.com/gnello/laravel-mattermost-driver).

#### V3

[](#v3)

If you want to install the [V3 Driver](https://github.com/gnello/php-mattermost-driver/tree/v1.3.0) instead of the V4 one you should do:

```
composer require gnello/php-mattermost-driver:1.*

```

Usage
-----

[](#usage)

### Authentication

[](#authentication)

#### Login id and password

[](#login-id-and-password)

```
 use \Gnello\Mattermost\Driver;

 $container = new \Pimple\Container([
     'driver' => [
         'url' => 'your_chat_url',
         'login_id' => 'your_login_id',
         'password' => 'your_password',
     ]
 ]);

 $driver = new Driver($container);
 $result = $driver->authenticate();
```

#### Token

[](#token)

```
 use \Gnello\Mattermost\Driver;

 $container = new \Pimple\Container([
     'driver' => [
         'url' => 'your_chat_url',
         'token' => 'your_token',
     ]
 ]);

 $driver = new Driver($container);
 $result = $driver->authenticate();
```

### Options

[](#options)

Below a list of all the Driver available options, for the Guzzle options please refer to its [official documentation](https://docs.guzzlephp.org/en/stable/request-options.html).

OptionDefault valueDescriptionscheme"https"The URI scheme.basePath"/api/v4"The base path of the API endpoint.url"localhost"The URL of the Mattermost server, without the scheme (es. "[www.mydomain.com](http://www.mydomain.com)").login\_idnullThe account username to use with the API.passwordnullThe account password to use with the API.tokennullThe account token to use with the API, if specified it override the login\_id and password.You can specify the options as shown in the following example:

```
 use \Gnello\Mattermost\Driver;

 $container = new \Pimple\Container([
     'driver' => [
         //put here any options for the driver
     ],
     'guzzle' => [
         //put here any options for Guzzle
     ]
 ]);

 $driver = new Driver($container);
 $result = $driver->authenticate();
```

### Check results

[](#check-results)

This Driver follows the [PSR-7](http://www.php-fig.org/psr/psr-7/) document therefore any response is a ResponseInterface type:

```
if ($result->getStatusCode() == 200) {
    echo "Everything is ok.";
    var_dump(json_decode($result->getBody()));
} else {
    echo "HTTP ERROR " . $result->getStatusCode();
}
```

### Users endpoint

[](#users-endpoint)

```
//Add a new user
$result = $driver->getUserModel()->createUser([
    'email'    => 'test@test.com',
    'username' => 'test',
    'password' => 'testpsw'
]);

//Get a user
$result = $driver->getUserModel()->getUserByUsername('username');

//Please read the UserModel class or refer to the api documentation for a complete list of available methods.
```

### Channels endpoint

[](#channels-endpoint)

```
//Create a channel
$result = $driver->getChannelModel()->createChannel([
    'name'         => 'new_channel',
    'display_name' => 'New Channel',
    'type'         => 'O',
]);

//Get a channel
$result = $driver->getChannelModel()->getChannelByName('team_id_of_the_channel_to_return', 'new_channel');

//Search a channel
$result = $driver->getChannelModel()->searchChannels($teamId, [
    'term' => "full or partial name or display name of channels"
]);

//Please read the ChannelModel class or refer to the api documentation for a complete list of available methods.
```

### Posts endpoint

[](#posts-endpoint)

```
//Create a post
$result = $driver->getPostModel()->createPost([
    'channel_id' => 'The channel ID to post in',
    'message' => 'The message contents, can be formatted with Markdown',
]);

//Get a post
$result = $driver->getPostModel()->getPost('post_id_of_the_post_to_return');

//Please read the PostModel class or refer to the api documentation for a complete list of available methods.
```

### Files endpoint

[](#files-endpoint)

```
//Upload a file
$result = $driver->getFileModel()->uploadFile([
    'channel_id' => 'The ID of the channel that this file will be uploaded to',
    'filename' => 'The name of the file to be uploaded',
    'files' => fopen('Path of the file to be uploaded', 'rb'),
]);

//Send a post with the file just uploaded
$result = $driver->getPostModel()->createPost([
    'channel_id' => 'The channel ID to post in',
    'message' => 'The message contents, can be formatted with Markdown',
    'file_ids' => 'A list of file IDs to associate with the post',
]);

//Please read the FileModel class or refer to the api documentation for a complete list of available methods.
```

### Preferences endpoint

[](#preferences-endpoint)

```
//Get a list of the user's preferences
$result = $driver->getPreferenceModel('user_id')->getUserPreference();

//Please read the PreferenceModel class or refer to the api documentation for a complete list of available methods.
```

Endpoints supported
-------------------

[](#endpoints-supported)

- [Bleve](https://api.mattermost.com/#tag/bleve)
- [Bots](https://api.mattermost.com/#tag/bots)
- [Brand](https://api.mattermost.com/#tag/brand)
- [Channels](https://api.mattermost.com/#tag/channels)
- [Cluster](https://api.mattermost.com/#tag/cluster)
- [Commands](https://api.mattermost.com/#tag/commands)
- [Compliance](https://api.mattermost.com/#tag/compliance)
- [DataRetention](https://api.mattermost.com/#tag/dataretention)
- [Elasticsearch](https://api.mattermost.com/#tag/elasticsearch)
- [Emoji](https://api.mattermost.com/#tag/emoji)
- [Files](https://api.mattermost.com/#tag/files)
- [Groups](https://api.mattermost.com/#tag/groups)
- [Integration Actions](https://api.mattermost.com/#tag/integration_actions)
- [Jobs](https://api.mattermost.com/#tag/jobs)
- [LDAP](https://api.mattermost.com/#tag/LDAP)
- [OAuth](https://api.mattermost.com/#tag/OAuth)
- [Plugins](https://api.mattermost.com/#tag/plugins)
- [Posts](https://api.mattermost.com/#tag/posts)
- [Preferences](https://api.mattermost.com/#tag/preferences)
- [Reactions](https://api.mattermost.com/#tag/reactions)
- [Roles](https://api.mattermost.com/#tag/roles)
- [SAML](https://api.mattermost.com/#tag/SAML)
- [Schemes](https://api.mattermost.com/#tag/schemes)
- [Status](https://api.mattermost.com/#tag/status)
- [System](https://api.mattermost.com/#tag/system)
- [Teams](https://api.mattermost.com/#tag/teams)
- [Threads](https://api.mattermost.com/#tag/threads)
- [Users](https://api.mattermost.com/#tag/users)
- [Webhooks](https://api.mattermost.com/#tag/webhooks)

Don't you see the endpoint you need? Feel free to open an issue or a PR!

Contact
-------

[](#contact)

-

###  Health Score

52

—

FairBetter than 96% of packages

Maintenance46

Moderate activity, may be stable

Popularity50

Moderate usage in the ecosystem

Community29

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor1

Top contributor holds 80.1% 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 ~80 days

Recently: every ~237 days

Total

37

Last Release

416d ago

Major Versions

v1.3.0 → v2.0.02017-05-14

PHP version history (2 changes)v1.0.0PHP &gt;=5.4.0

v2.4.0PHP &gt;=5.5.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/3364624b5ca65e5501822875f02a9546c09224ea148f4c3bdf1c81f55f793802?d=identicon)[gnello](/maintainers/gnello)

---

Top Contributors

[![gnello](https://avatars.githubusercontent.com/u/19245006?v=4)](https://github.com/gnello "gnello (161 commits)")[![prixone](https://avatars.githubusercontent.com/u/13369829?v=4)](https://github.com/prixone "prixone (18 commits)")[![BrunoSpy](https://avatars.githubusercontent.com/u/954222?v=4)](https://github.com/BrunoSpy "BrunoSpy (8 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (6 commits)")[![jelly](https://avatars.githubusercontent.com/u/67428?v=4)](https://github.com/jelly "jelly (1 commits)")[![romanmatena](https://avatars.githubusercontent.com/u/164995?v=4)](https://github.com/romanmatena "romanmatena (1 commits)")[![scottliddick](https://avatars.githubusercontent.com/u/1240052?v=4)](https://github.com/scottliddick "scottliddick (1 commits)")[![AizeLeOuf](https://avatars.githubusercontent.com/u/8999614?v=4)](https://github.com/AizeLeOuf "AizeLeOuf (1 commits)")[![sheasollars](https://avatars.githubusercontent.com/u/78609870?v=4)](https://github.com/sheasollars "sheasollars (1 commits)")[![alexmorbo](https://avatars.githubusercontent.com/u/435562?v=4)](https://github.com/alexmorbo "alexmorbo (1 commits)")[![anx-dwuggenig](https://avatars.githubusercontent.com/u/48215438?v=4)](https://github.com/anx-dwuggenig "anx-dwuggenig (1 commits)")[![brettmc](https://avatars.githubusercontent.com/u/4978962?v=4)](https://github.com/brettmc "brettmc (1 commits)")

---

Tags

clientmattermostmattermost-clientchatMattermost

### Embed Badge

![Health badge](/badges/gnello-php-mattermost-driver/health.svg)

```
[![Health](https://phpackages.com/badges/gnello-php-mattermost-driver/health.svg)](https://phpackages.com/packages/gnello-php-mattermost-driver)
```

###  Alternatives

[neuron-core/neuron-ai

The PHP Agentic Framework.

1.8k245.3k21](/packages/neuron-core-neuron-ai)[theodo-group/llphant

LLPhant is a library to help you build Generative AI applications.

1.5k311.5k5](/packages/theodo-group-llphant)[guanguans/notify

Push notification SDK(AnPush、Bark、Chanify、DingTalk、Discord、Gitter、GoogleChat、IGot、Lark、Mattermost、MicrosoftTeams、NowPush、Ntfy、Push、Pushback、PushBullet、PushDeer、PushMe、Pushover、PushPlus、QQ、RocketChat、ServerChan、ShowdocPush、SimplePush、Slack、Telegram、WeWork、WPush、XiZhi、YiFengChuanHua、ZohoCliq、ZohoCliqWebHook、Zulip).

682104.9k7](/packages/guanguans-notify)[oat-sa/tao-core

TAO core extension

66136.7k74](/packages/oat-sa-tao-core)[get-stream/stream-chat

A PHP client for Stream Chat (https://getstream.io/chat/)

301.8M2](/packages/get-stream-stream-chat)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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