marktic/embeddable

Embeddable widgets library for SaaS applications

Maintainers

Package info

github.com/marktic/embeddable

pkg:composer/marktic/embeddable

Statistics

Installs: 5

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

dev-main 2026-03-28 17:25 UTC

This package is auto-updated.

Last update: 2026-03-28 17:25:31 UTC


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;
    }
}