cleentfaar/slack
PHP Slack API client that maps Slack Web API methods to dedicated payload and response objects. Uses JMS Serializer for spec-aligned data models, supports OAuth/tokens, and provides examples plus event hooks around the ApiClient.
Pros:
Payload classes), aligning well with Laravel’s Eloquent/Repository patterns. This reduces boilerplate for API calls and improves maintainability.EventDispatcher (compatible with Laravel’s event system), enabling extensibility (e.g., logging, analytics, or custom business logic hooks).Cons:
reactions.*, pins.*, team.*) are unimplemented, requiring custom workarounds or forks.EventDispatcher, Yaml), which may bloat the project if not already in use. Laravel’s native alternatives (e.g., Illuminate\Support\Events) could replace these with minimal effort.Illuminate\Cache), or queue systems (e.g., Illuminate\Queue).Laravel Compatibility:
guzzlehttp/guzzle (v6): Compatible with Laravel’s HTTP client.jms/serializer: Functional but may conflict with Laravel’s native JSON handling (e.g., json_encode()).symfony/event-dispatcher: Can be replaced with Laravel’s Illuminate\Support\Facades\Event.bind(ApiClient::class, fn() => new ApiClient(config('slack.token')))).Slack API Changes:
config() or .env files should manage credentials.Payload classes or delegate to Slack’s HTTP client directly.Http::post()) might suffice.jms/serializer with Laravel’s collect() or json_decode() for simple cases.Event system instead of Symfony’s EventDispatcher to avoid dependency bloat.Http facade. Override the ApiClient to inject Laravel’s client for consistency:
$client = new \GuzzleHttp\Client(['base_uri' => 'https://slack.com/api']);
$apiClient = new \CL\Slack\ApiClient(config('slack.token'), $client);
ApiClient as a singleton in AppServiceProvider:
$this->app->singleton(\CL\Slack\ApiClient::class, fn($app) =>
new \CL\Slack\ApiClient($app['config']['slack.token'])
);
EventDispatcher with Laravel’s:
use Illuminate\Support\Facades\Event;
// Dispatch events manually or create a decorator for ApiClient.
User, Channel). Example:
$users = $apiClient->usersList()->getUsers();
return User::insert($users->map(fn($user) => [
'id' => $user->id,
'name' => $user->profile->real_name,
]));
conversations.history) to Laravel queues:
SlackMessageSyncJob::dispatch($channelId)->onQueue('slack');
// Using the package
$apiClient->chatPostMessage([
'channel' => '#general',
'text' => 'Hello from Laravel!',
]);
// Custom alternative
Http::post('https://slack.com/api/chat.postMessage', [
'channel' => '#general',
'text' => 'Hello from Laravel!',
])->throw();
reactions.add) and submit PRs upstream (if feasible).composer.json to require PHP ≥8.1 and add return_type_declaration, strict_types, and array_syntax checks.create_function, each()).Yaml with Laravel’s config() or files() helpers.EventDispatcher to use Laravel’s Event facade.Phase 1: Setup and Configuration
--ignore-platform-reqs if PHP version conflicts exist)..env and bind the ApiClient to the container.Phase 2: Core Functionality
chat.postMessage, users.list).Slack::postToChannel($channel, $message)).Phase 3: Event Handling
Event system or use Laravel’s Bus for async processingHow can I help you explore Laravel packages today?