2018-12-08 07:12:05 +00:00
|
|
|
# Matrix client SDK for php
|
2015-02-20 21:36:34 +00:00
|
|
|
[![Software License][ico-license]](LICENSE.md)
|
2013-08-07 17:33:05 +00:00
|
|
|
|
2018-12-08 07:12:05 +00:00
|
|
|
This is a Matrix client-server SDK for php 7.0+, mostly copied from [matrix-org/matrix-python-sdk][python-pck]
|
2013-08-07 17:33:05 +00:00
|
|
|
|
2018-12-08 07:12:05 +00:00
|
|
|
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
|
|
|
|
- No live sync, because I'm not going to go into php multithreading
|
2021-05-10 03:32:24 +00:00
|
|
|
- Unit tests for the client
|
2016-12-15 18:26:32 +00:00
|
|
|
|
2018-12-08 07:12:05 +00:00
|
|
|
## Installation
|
2016-12-15 18:26:32 +00:00
|
|
|
|
2021-05-10 03:32:24 +00:00
|
|
|
```
|
|
|
|
composer require aryess/php-matrix-sdk
|
2016-12-15 18:26:32 +00:00
|
|
|
```
|
|
|
|
|
2018-12-08 07:12:05 +00:00
|
|
|
## Usage
|
|
|
|
Client:
|
|
|
|
```php
|
|
|
|
require('vendor/autoload.php');
|
|
|
|
use Aryess\PhpMatrixSdk\MatrixClient;
|
2016-12-15 18:26:32 +00:00
|
|
|
|
2018-12-08 07:12:05 +00:00
|
|
|
$client = new MatrixClient("http://localhost:8008");
|
2013-08-07 17:33:05 +00:00
|
|
|
|
2018-12-08 07:12:05 +00:00
|
|
|
// New user
|
|
|
|
$token = $client->registerWithPassword("foobar", "monkey");
|
2013-08-07 17:33:05 +00:00
|
|
|
|
2018-12-08 07:12:05 +00:00
|
|
|
// Existing user
|
|
|
|
$token = $client->login("foobar", "monkey");
|
|
|
|
|
|
|
|
$room = $client->createRoom("my_room_alias");
|
|
|
|
$room->sendText("Hello!");
|
2013-08-07 17:33:05 +00:00
|
|
|
```
|
|
|
|
|
2018-12-08 07:12:05 +00:00
|
|
|
API:
|
|
|
|
```php
|
|
|
|
require('vendor/autoload.php');
|
|
|
|
use Aryess\PhpMatrixSdk\MatrixHttpApi;
|
2013-08-07 17:33:05 +00:00
|
|
|
|
2018-12-08 07:12:05 +00:00
|
|
|
$matrix = new MatrixHttpApi("http://localhost:8008", $sometoken);
|
|
|
|
|
|
|
|
$response = $matrix->sendMessage("!roomid:matrix.org", "Hello!");
|
2013-08-07 17:33:05 +00:00
|
|
|
```
|
|
|
|
|
2018-12-08 07:12:05 +00:00
|
|
|
##Structure
|
|
|
|
The SDK is split into two modules: ``api`` and ``client``.
|
2015-05-13 18:56:38 +00:00
|
|
|
|
2018-12-08 07:12:05 +00:00
|
|
|
###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.
|
2015-05-13 18:56:38 +00:00
|
|
|
|
2018-12-08 07:12:05 +00:00
|
|
|
###Client
|
|
|
|
This encapsulates the API module and provides object models such as ``Room``.
|
2013-08-07 17:33:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
## Contributing
|
|
|
|
|
2017-08-21 20:30:22 +00:00
|
|
|
Please see [CONTRIBUTING](CONTRIBUTING.md) and [CODE_OF_CONDUCT](CODE_OF_CONDUCT.md) for details.
|
2013-08-07 17:33:05 +00:00
|
|
|
|
2015-02-04 19:40:00 +00:00
|
|
|
## Security
|
|
|
|
|
2018-11-27 11:01:37 +00:00
|
|
|
If you discover any security related issues, please email aryess@github.com instead of using the issue tracker.
|
2015-02-04 19:40:00 +00:00
|
|
|
|
2013-08-07 17:33:05 +00:00
|
|
|
## Credits
|
|
|
|
|
2018-11-27 11:01:37 +00:00
|
|
|
- [Yoann Celton][link-author]
|
2015-02-20 21:36:34 +00:00
|
|
|
- [All Contributors][link-contributors]
|
2013-08-07 17:33:05 +00:00
|
|
|
|
|
|
|
## License
|
|
|
|
|
2014-10-25 20:57:34 +00:00
|
|
|
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
|
2015-02-20 21:36:34 +00:00
|
|
|
|
2018-11-27 11:01:37 +00:00
|
|
|
[ico-version]: https://img.shields.io/packagist/v/Aryess/PhpMatrixSdk.svg?style=flat-square
|
2015-02-20 21:36:34 +00:00
|
|
|
[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square
|
2018-11-27 11:01:37 +00:00
|
|
|
[ico-travis]: https://img.shields.io/travis/Aryess/PhpMatrixSdk/master.svg?style=flat-square
|
|
|
|
[ico-scrutinizer]: https://img.shields.io/scrutinizer/coverage/g/Aryess/PhpMatrixSdk.svg?style=flat-square
|
|
|
|
[ico-code-quality]: https://img.shields.io/scrutinizer/g/Aryess/PhpMatrixSdk.svg?style=flat-square
|
|
|
|
[ico-downloads]: https://img.shields.io/packagist/dt/Aryess/PhpMatrixSdk.svg?style=flat-square
|
|
|
|
|
|
|
|
[link-packagist]: https://packagist.org/packages/Aryess/PhpMatrixSdk
|
|
|
|
[link-travis]: https://travis-ci.org/Aryess/PhpMatrixSdk
|
|
|
|
[link-scrutinizer]: https://scrutinizer-ci.com/g/Aryess/PhpMatrixSdk/code-structure
|
|
|
|
[link-code-quality]: https://scrutinizer-ci.com/g/Aryess/PhpMatrixSdk
|
|
|
|
[link-downloads]: https://packagist.org/packages/Aryess/PhpMatrixSdk
|
|
|
|
[link-author]: https://github.com/aryess
|
2015-02-20 21:36:34 +00:00
|
|
|
[link-contributors]: ../../contributors
|
2021-05-10 03:32:24 +00:00
|
|
|
[python-pck]: https://github.com/matrix-org/matrix-python-sdk
|