Microsoft Adaptive Cards builder for PHP
A fluent, fully typed PHP builder for Microsoft Adaptive Cards.
- PHP:
>= 8.1 - Extensions:
ext-json
Install the package via Composer:
composer require garis-kode/adaptivecard-phpCreate an Adaptive Card with a formatted text block and an action button, and export to JSON:
<?php
declare(strict_types=1);
require_once __DIR__ . '/vendor/autoload.php';
use AdaptiveCards\Action\OpenUrl\OpenUrlAction;
use AdaptiveCards\AdaptiveCard;
use AdaptiveCards\Element\TextBlock;
use AdaptiveCards\Enum\TextSize;
use AdaptiveCards\Enum\TextWeight;
$card = AdaptiveCard::make('1.6') // Version defaults to '1.6' if omitted
->addTextBlock('Hello from Adaptive Cards!', function (TextBlock $t): void {
$t->size(TextSize::Large)
->weight(TextWeight::Bolder);
})
->addAction(OpenUrlAction::make('https://adaptivecards.io/', 'Learn More'));
// Output JSON string
echo $card->toJson();{
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"type": "AdaptiveCard",
"version": "1.6",
"body": [
{
"type": "TextBlock",
"text": "Hello from Adaptive Cards!",
"size": "Large",
"weight": "Bolder"
}
],
"actions": [
{
"type": "Action.OpenUrl",
"url": "https://adaptivecards.io/",
"title": "Learn More"
}
]
}For comprehensive schema specifications, interactive designer, and payload samples, refer to the official Adaptive Cards Documentation.
This project adheres to Semantic Versioning. For a complete record of updates and release notes, visit the GitHub Releases page.
- License: Released under the MIT License. Copyright © 2026 Garis Kode.
- Adaptive Cards Specification: Adaptive Cards is an open card exchange format developed by Microsoft. Learn more at Adaptive Cards.