Rocket.chat API wrapper for Laravel.
visifo-php/laravel-rocketchat-api-wrapper is a Laravel package for rocket.chat api wrapper for laravel..
It currently has 1 GitHub stars and 97 downloads on Packagist (latest version 0.3.7).
Install it with composer require visifo-php/laravel-rocketchat-api-wrapper.
Discover more Laravel packages by visifo-php
or browse all Laravel packages to compare alternatives.
Last updated
This is a Laravel RocketChat REST API Wrapper. It's simple to use, typesafe and object-oriented.
You can install the package via composer:
composer require visifo-php/laravel-rocketchat-api-wrapper
You can publish the config file with:
php artisan vendor:publish --provider="visifo\Rocket\RocketServiceProvider" --tag="laravel-rocketchat-api-wrapper-config"
You have to specify your RocketChat Url and the UserId and AuthToken to authenticate with the RocketChat API in your Laravel .env.
You only have to specify the Password if you use the users.update Endpoint, which requires 2FA
ROCKET_URL=your-rocketchat.com
ROCKET_USER_ID=RLhxwWHn9RjiWjtdG
ROCKET_AUTH_TOKEN=Z9__Y1_Es6OB2kMf4dBD3I6qygRT3s-Lla67pf8AU1p
# for users.update you need to set the Password
ROCKET_USER_PASSWORD=myPassword
You can send Requests to an Endpoint via the Endpoint Objects. You can get them from the RocketChat Client like this
$channelsEndpoint = \visifo\Rocket\rocketChat()->channels();
$chatEndpoint = \visifo\Rocket\rocketChat()->chat();
$commandsEndpoint = \visifo\Rocket\rocketChat()->commands();
$rolesEndpoint = \visifo\Rocket\rocketChat()->roles();
$usersEndpoint = \visifo\Rocket\rocketChat()->users();
From there you can make API calls
$channel = $channelsEndpoint->create("myChannel");
// $channel has Type: visifo\Rocket\Objects\Channels\Channel
$channelsEndpoint->setTopic($channel->id, "myTopic")
All functions who return the Response from RocketChat will deserialize it into its own simplified Object. Also, some properties gets renamed to something more simple or meaningful, for example "t" to "type" or "_id" to "id"
Alternatively you can make Requests directly via the RocketChat Client which will result in the raw stdClass you get from the RocketChat API
$rocketChatClient = \visifo\Rocket\rocketChat()
$channel = $rocketChatClient->post("channels.create", ['name' => 'myChannel']);
// $channel has Type: stdClass
$rocketChatClient->post("channels.setTopic", ['roomId' => $channel->_id, 'topic' => 'myTopic'])
composer test
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.