PHPackages                             vocphone/laravel-matrix-sdk - 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. vocphone/laravel-matrix-sdk

ActiveLibrary

vocphone/laravel-matrix-sdk
===========================

PHP SDK for interacting with Matrix/Synapse.

1.0.5(1y ago)067MITPHPPHP ~7.4|^8

Since Nov 7Pushed 1y ago1 watchersCompare

[ Source](https://github.com/vocphone/laravel-matrix-sdk)[ Packagist](https://packagist.org/packages/vocphone/laravel-matrix-sdk)[ Docs](https://github.com/vocphones/laravel-matrix-sdk)[ RSS](/packages/vocphone-laravel-matrix-sdk/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (6)Dependencies (3)Versions (8)Used By (0)

Matrix client SDK for Laravel
=============================

[](#matrix-client-sdk-for-laravel)

This package is a fork of the now-abandoned original by [Yoann Celton](https://github.com/Aryess). The architecture does not necessarily reflect best practice in the eyes of current maintainers. Incremental improvements are made as time and resources allow. Contributions are welcome.

---

[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Software Version](https://camo.githubusercontent.com/cc2380f3f5151badad569bcd7c70b4af9833ab63e924a74ecbc863d7dc363d85/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d6565742d6b696e6b73746572732f7068702d6d61747269782d73646b2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/vocphone/laravel-matrix-sdk)[![Software License](https://camo.githubusercontent.com/cac1f0d3a86d84eb1290613bf527a94c3e3d2ab86ada075c107efe3d1c6d96a3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d6565742d6b696e6b73746572732f7068702d6d61747269782d73646b2e7376673f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/cac1f0d3a86d84eb1290613bf527a94c3e3d2ab86ada075c107efe3d1c6d96a3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d6565742d6b696e6b73746572732f7068702d6d61747269782d73646b2e7376673f7374796c653d666c61742d737175617265)

This is a Matrix client-server SDK for php 7.4+, initially copied from [matrix-org/matrix-python-sdk](https://github.com/matrix-org/matrix-python-sdk) and then forked from [meet-kinksters/php-matrix-sdk](https://github.com/vocphone/laravel-matrix-sdk)

This package is still a work in progress, and at the current time, not everything has been ported:

- Missing E2E encryption, need php bindings for the OLM library
- Live sync
- Unit tests for the client

At the time of writing this, most sdks are lacking in the ability to use spaces, this sdk is space aware.

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

[](#installation)

```
composer require vocphone/laravel-matrix-sdk

```

Configuration
-------------

[](#configuration)

The most simple way to integrate is to add the following environment variables, the app will then cache the login token ( forever ) to assist with speed and perform less logins

```
MATRIX_URL=https://matrix.org
MATRIX_USERNAME=username
MATRIX_PASSWORD=password

```

Usage
-----

[](#usage)

### Basic Usage

[](#basic-usage)

#### Send Message

[](#send-message)

```
use Vocphone\LaravelMatrixSdk\MatrixClient;

$message = 'My Laravel Test Message';
$roomId = '!someRoom:matrix.org';

app(MatrixClient::class)->sendMessage($message, $roomId);
```

### Notifications

[](#notifications)

There is the ability to send messages directly into matrix.

#### Notifiable

[](#notifiable)

```
use Illuminate\Notifications\Notifiable;

class User extends Model
{
    use Notifiable;

    public function routeNotificationForMatrix($notification) {
        // If the roomId is null then the message won't attempt to send to matrix
        $roomId = $this->matrix_user_room_id ?? null;

        return $roomId;
    }
}
```

#### Notification

[](#notification)

create a notification that returns the message content from the `toMatrix` method

```
use Illuminate\Notifications\Notification;

class MatrixNotification extends Notification
{
    private $message;
    public function __Construct( string $message ) {
        $this->message = $message;
    }

    public function toMatrix( $notifiable ) {
        return $this->message;
    }
}
```

### Spaces

[](#spaces)

#### Create a Space

[](#create-a-space)

```
use Vocphone\LaravelMatrixSdk\MatrixClient;

$matrix = app(MatrixClient::class);

$spaceName = 'My Cool Space';
$public = false; // No way man, it's just for me
$invitees = []; // just me for now
$isSpace = true;
$space = $matrix->createRoom( $spaceName, $public, $invitees, $isSpace);
```

#### Add User to a space

[](#add-user-to-a-space)

```
use Vocphone\LaravelMatrixSdk\MatrixClient;

$inviteUserId = '@new_user:matrix.org';

// get the matrix client instance
$matrix = app(MatrixClient::class);
// make sure we have all the current known information
$matrix->sync();
foreach( $matrix->getRooms() as $room ) {
    if( $room->getIsSpace() ) {
        $room->inviteUser($inviteUserId);
    }
}
```

Structure
---------

[](#structure)

The SDK is split into two modules: `api` and `client`.

### API

[](#api)

This contains the raw HTTP API calls and has minimal business logic. You can set the access token (`token`) to use for requests as well as set a custom transaction ID (`txn_id`) which will be incremented for each request.

### Client

[](#client)

This encapsulates the API module and provides object models such as `Room`.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) and [CODE\_OF\_CONDUCT](CODE_OF_CONDUCT.md) for details.

Security
--------

[](#security)

If you discover any security related issues, please email instead of using the issue tracker.

Credits
-------

[](#credits)

- [Tom Higgins](https://github.com/vocphone) at [Vocphone](https://vocphone.com)
- [Brad Jones](https://github.com/bradjones1) at [Meet Kinksters](https://tech.kinksters.dating)
- [Yoann Celton](https://github.com/Aryess) (initial port)
- [All Contributors](https://github.com/meet-kinksters/php-matrix-sdk/graphs/contributors)

License
-------

[](#license)

[MIT License](LICENSE.md).

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance39

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community20

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor3

3 contributors hold 50%+ of commits

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 ~6 days

Total

6

Last Release

520d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/330d6f05980ca525af4c77b3dbe0a48246c33c4a609afaa2c42f271868511cb6?d=identicon)[vocphone-support](/maintainers/vocphone-support)

---

Top Contributors

[![philsturgeon](https://avatars.githubusercontent.com/u/67381?v=4)](https://github.com/philsturgeon "philsturgeon (49 commits)")[![frankdejonge](https://avatars.githubusercontent.com/u/534693?v=4)](https://github.com/frankdejonge "frankdejonge (38 commits)")[![bradjones1](https://avatars.githubusercontent.com/u/981966?v=4)](https://github.com/bradjones1 "bradjones1 (24 commits)")[![vocphone-tom](https://avatars.githubusercontent.com/u/142958146?v=4)](https://github.com/vocphone-tom "vocphone-tom (18 commits)")[![ravage84](https://avatars.githubusercontent.com/u/625761?v=4)](https://github.com/ravage84 "ravage84 (10 commits)")[![jotaelesalinas](https://avatars.githubusercontent.com/u/2042875?v=4)](https://github.com/jotaelesalinas "jotaelesalinas (8 commits)")[![hansott](https://avatars.githubusercontent.com/u/3886384?v=4)](https://github.com/hansott "hansott (7 commits)")[![RobLoach](https://avatars.githubusercontent.com/u/25086?v=4)](https://github.com/RobLoach "RobLoach (7 commits)")[![bcrowe](https://avatars.githubusercontent.com/u/752603?v=4)](https://github.com/bcrowe "bcrowe (5 commits)")[![browner12](https://avatars.githubusercontent.com/u/5232313?v=4)](https://github.com/browner12 "browner12 (5 commits)")[![EmanueleMinotto](https://avatars.githubusercontent.com/u/417201?v=4)](https://github.com/EmanueleMinotto "EmanueleMinotto (5 commits)")[![colinodell](https://avatars.githubusercontent.com/u/202034?v=4)](https://github.com/colinodell "colinodell (5 commits)")[![reinink](https://avatars.githubusercontent.com/u/882133?v=4)](https://github.com/reinink "reinink (5 commits)")[![marcqualie](https://avatars.githubusercontent.com/u/101022?v=4)](https://github.com/marcqualie "marcqualie (4 commits)")[![gmponos](https://avatars.githubusercontent.com/u/5675248?v=4)](https://github.com/gmponos "gmponos (4 commits)")[![hassankhan](https://avatars.githubusercontent.com/u/1781985?v=4)](https://github.com/hassankhan "hassankhan (3 commits)")[![jclyons52](https://avatars.githubusercontent.com/u/6395559?v=4)](https://github.com/jclyons52 "jclyons52 (3 commits)")[![mAAdhaTTah](https://avatars.githubusercontent.com/u/4371429?v=4)](https://github.com/mAAdhaTTah "mAAdhaTTah (2 commits)")[![assertchris](https://avatars.githubusercontent.com/u/200609?v=4)](https://github.com/assertchris "assertchris (2 commits)")[![vazaha-nl](https://avatars.githubusercontent.com/u/1075085?v=4)](https://github.com/vazaha-nl "vazaha-nl (2 commits)")

---

Tags

phpmatrixMatrix ChatSynapse

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/vocphone-laravel-matrix-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/vocphone-laravel-matrix-sdk/health.svg)](https://phpackages.com/packages/vocphone-laravel-matrix-sdk)
```

###  Alternatives

[mailchimp/transactional

458.9M16](/packages/mailchimp-transactional)

PHPackages © 2026

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