marktic/embeddable
Composer 安装命令:
composer require marktic/embeddable
包简介
Embeddable widgets library for SaaS applications
README 文档
README
Embeddable widgets library for SaaS applications. Provides a framework for defining, configuring, and embedding iframe-based widgets in external sites.
Features
- Define widgets as PHP classes with typed configurable properties
- Auto-generate embed HTML (
<iframe>+ optional<script>) - Admin bundle with a widget builder UI (tabbed interface, customize form, live preview, copy-to-clipboard embed code)
- Property types:
TextProperty,NumberProperty,SelectProperty,CheckboxProperty
Installation
composer require marktic/embeddable
Usage
Define a Widget
use Marktic\Embeddable\Widgets\AbstractWidget; use Marktic\Embeddable\WidgetProperties\TextProperty; use Marktic\Embeddable\WidgetProperties\SelectProperty; class MyWidget extends AbstractWidget { public function getName(): string { return 'my-widget'; } public function getLabel(): string { return 'My Widget'; } public function getProperties(): array { return [ new TextProperty('title', 'Title', 'Default Title'), new SelectProperty('theme', 'Theme', ['light' => 'Light', 'dark' => 'Dark'], 'light'), ]; } protected function getBaseUrl(): string { return 'https://myapp.com/widgets/my-widget'; } }
Define a Widget Collection
use Marktic\Embeddable\Widgets\WidgetsCollection; class MyWidgets extends WidgetsCollection { protected static function widgetClasses(): array { return [ 'my-widget' => MyWidget::class, ]; } }
Get Embed HTML
$widget = new MyWidget(); echo $widget->getHtml(); // or with parameters: echo $widget->getHtml(['theme' => 'dark', 'title' => 'Hello']);
Admin Bundle Controller
use Marktic\Embeddable\Bundle\Modules\Admin\Controllers\HasWidgetsControllerTrait; class MyWidgetsController { use HasWidgetsControllerTrait; protected function getWidgetsClass(): string { return MyWidgets::class; } }
统计信息
- 总下载量: 5
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 4
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-03-28