tiagomichaelsousa/slack-laravel

A slack sdk for laravel

v0.2.0 2023-06-30 17:04 UTC

This package is auto-updated.

Last update: 2024-04-29 12:53:43 UTC


README

Slack Laravel

GitHub Workflow Status (main) Total Downloads Latest Version License

Slack Laravel is a non-official PHP API package that allows you to interact with the Slack API ⚡️

This package is still under development. There may have methods that are still not implemented.

Get Started

The official documentation for the Slack Client will be available soon. 👀

Until there you can still explore the SDK development experience with the users(), conversations() and reminders() methods 🚀

Requires PHP 8.1+

First, install Slack Laravel via the Composer package manager:

composer require tiagomichaelsousa/slack-laravel

Next, publish the configuration file:

php artisan vendor:publish --provider="Slack\Laravel\ServiceProvider"

This will create a config/slack.php configuration file in your project, which you can modify to your needs using environment variables:

SLACK_TOKEN=xoxb-...

Finally, you may use the Slack facade to access the Slack API:

use Slack\Laravel\Facades\Slack;

$conversations = Slack::conversations()->create('foo');

echo $conversations->channel->name;

Usage

For usage examples, take a look at the tiagomichaelsousa/slack-client repository.

Testing

The Slack facade provides a fake() method that allows you to fake the API responses.

All responses are having a fake() method that allows you to easily create a response object by only providing the parameters relevant for your test case.

use Slack\Laravel\Facades\Slack;
use Slack\Responses\Conversation\CreateConversationResponse;

Slack::fake([
    CreateConversationResponse::fake([
        'channel' => [
            'name' => 'foo',
        ],
    ]);
]);

$conversations = Slack::conversations()->create('foo');

expect($conversations->channel)->name->toBe('foo');

The official documentation for the Slack Client for Laravel will be available soon. 👀

Slack Client for Laravel is an open-sourced software licensed under the MIT license.