ejtj3/teams
Simple PHP 7.2+ connector for sending Microsoft Teams messages via Incoming Webhooks. Build and send MessageCards with fluent syntax: add text, title, theme color, sections with facts/images, and interactive actions/inputs. Includes Symfony bundle option.
Pros:
Cons:
return_type declarations in methods) or PSR standards (e.g., PSR-15 middleware).Laravel-Specific Challenges:
file_get_contents() for webhook sends, which is deprecated and lacks modern features like retries or timeouts.Client class; no Laravel-friendly config system.Webhook Dependency:
file_get_contents).file_get_contents() halts execution until the request completes, risking Laravel request timeouts..env).shouldQueue()).Http::post().Client class in unit tests..env, Vault, or database).ejtj3/teams to composer.json.Client to Laravel’s container.// app/Services/TeamsNotifier.php
public function sendAlert(string $message) {
$client = new \EJTJ3\Teams\Client(config('teams.webhook_url'));
$card = (new \EJTJ3\Teams\Card($message))
->setThemeColor(\EJTJ3\Teams\Card::STATUS_CRITICAL);
$client->send($card);
}
// app/Facades/Teams.php
public static function alert(string $message) {
return app(TeamsClient::class)->send(
(new Card($message))->setThemeColor(Card::STATUS_CRITICAL)
);
}
// Use Laravel Queues to avoid timeouts
Queue::push(function () use ($client, $card) {
try {
$client->send($card);
} catch (\Exception $e) {
Log::error("Teams send failed: " . $e->getMessage());
}
});
public function sendWithFallback($client, $card) {
try {
$client->send($card);
} catch (\Exception $e) {
// Fallback to direct HTTP
Http::post(config('teams.webhook_url'), [
'text' => $card->getTitle() ?? 'Fallback message'
]);
}
}
Client to test card construction.// app/Providers/TeamsServiceProvider.php
public function register() {
$this->app->singleton(TeamsClient::class, function () {
return new \EJTJ3\Teams\Client(config('teams.webhook_url'));
});
}
// config/teams.php
return [
'webhook_url' => env('TEAMS_WEBHOOK_URL'),
'default_theme' => \EJTJ3\Teams\Card::STATUS_DEFAULT,
];
Client::send() to log failures and payloads.HttpClient with Laravel’s Http or Guzzle.config/teams.php.How can I help you explore Laravel packages today?