garis-kode / adaptivecard-php
Fluent PHP builder that programmatically constructs Microsoft Adaptive Card (v1.6) JSON payloads.
v1.0.1
2026-10-25 13:06 UTC
Requires
- php: >=8.1
- ext-json: *
- justinrainbow/json-schema: ^5.2 || ^6.0
Requires (Dev)
- phpstan/phpstan: ^2.1 || ^2.3
- phpunit/phpunit: ^10.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-11-01 04:10:22 UTC
README
Microsoft Adaptive Cards builder for PHP
Overview
A fluent, fully typed PHP builder for Microsoft Adaptive Cards.
Requirements
- PHP:
>= 8.1 - Extensions:
ext-json
Installation
Install the package via Composer:
composer require garis-kode/adaptivecard-php
Quick Start
Create 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();
Expected Output
{
"$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"
}
]
}
Documentation
For comprehensive schema specifications, interactive designer, and payload samples, refer to the official Adaptive Cards Documentation.
Changelog
This project adheres to Semantic Versioning. For a complete record of updates and release notes, visit the GitHub Releases page.
License & Credits
- 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.