1# Matrix client SDK for PHP
2[![Software License][ico-license]](LICENSE.md)
3[![Software Version][ico-version]](https://packagist.org/packages/meet-kinksters/php-matrix-sdk)
4![Software License][ico-downloads]
5
6This is a Matrix client-server SDK for php 7.4+, initially copied from
7[matrix-org/matrix-python-sdk][python-pck].
8
9This package is still a work in progress, and at the current time, not everything has been ported:
10- Missing E2E encryption, need php bindings for the OLM library
11- Live sync
12- Unit tests for the client
13
14## Installation
15
16```
17composer require meet-kinksters/php-matrix-sdk
18```
19
20## Usage
21Client:
22```php
23require('vendor/autoload.php');
24use MatrixPhp\MatrixClient;
25
26$client = new MatrixClient("http://localhost:8008");
27
28// New user
29$token = $client->registerWithPassword("foobar", "monkey");
30
31// Existing user
32$token = $client->login("foobar", "monkey");
33
34$room = $client->createRoom("my_room_alias");
35$room->sendText("Hello!");
36```
37
38API:
39```php
40require('vendor/autoload.php');
41use MatrixPhp\MatrixHttpApi;
42
43$matrix = new MatrixHttpApi("http://localhost:8008", $sometoken);
44
45$response = $matrix->sendMessage("!roomid:matrix.org", "Hello!");
46```
47
48##Structure
49The SDK is split into two modules: ``api`` and ``client``.
50
51###API
52This contains the raw HTTP API calls and has minimal business logic. You can
53set the access token (``token``) to use for requests as well as set a custom
54transaction ID (``txn_id``) which will be incremented for each request.
55
56###Client
57This encapsulates the API module and provides object models such as ``Room``.
58
59## Contributing
60
61Please see [CONTRIBUTING](CONTRIBUTING.md) and [CODE_OF_CONDUCT](CODE_OF_CONDUCT.md) for details.
62
63## Security
64
65If you discover any security related issues, please email brad@kinksters.dating
66instead of using the issue tracker.
67
68## Credits
69
70- [Brad Jones](https://github.com/bradjones1) at [Meet Kinksters](https://tech.kinksters.dating)
71- [Yoann Celton](https://github.com/Aryess) (initial port)
72- [All Contributors](https://github.com/meet-kinksters/php-matrix-sdk/graphs/contributors)
73
74## License
75
76[MIT License](LICENSE.md).
77
78[ico-version]: https://img.shields.io/packagist/v/meet-kinksters/php-matrix-sdk.svg?style=flat-square
79[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square
80[ico-downloads]: https://img.shields.io/packagist/dt/meet-kinksters/php-matrix-sdk.svg?style=flat-square
81[python-pck]: https://github.com/matrix-org/matrix-python-sdk
82