mcoredev/tailor-blocks

Framework-agnostic PHP block content engine with YAML definitions and admin builder UI.

Maintainers

Package info

github.com/mcoredev/tailor-blocks

pkg:composer/mcoredev/tailor-blocks

Transparency log

Statistics

Installs: 1

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v0.1.0 2026-07-16 05:24 UTC

This package is auto-updated.

Last update: 2026-08-16 05:39:53 UTC


README

Tailor Blocks is a framework-agnostic PHP content engine for structured block content. Blocks are defined in YAML, edited through the bundled browser editor, validated and normalized by PHP, stored as JSON by your CMS, and compiled into frontend-ready JSON.

Tailor Blocks is not a CMS. Your application owns routing, persistence, authentication, authorization, uploads, search persistence, and frontend rendering.

Requirements

  • PHP 8.2+
  • Composer
  • ext-intl

Installation

composer require mcoredev/tailor-blocks

Drop-in CMS Integration

For an existing CMS, use the endpoint-first drop-in flow:

  1. Publish assets from vendor/mcoredev/tailor-blocks/dist/.
  2. Add a GET endpoint that returns EditorMountConfig JSON.
  3. Add a POST endpoint that sends editor.sync() JSON through TailorBlocksEngine::process(...).
  4. Store normalized content_json and derived compiled_json.

Start with the Drop-in CMS Integration guide and the copy-paste controller skeleton.

Assets

After Composer installation, copy or publish the built assets from vendor/mcoredev/tailor-blocks/dist/ into a public admin asset directory:

mkdir -p public/assets/vendor/tailor-blocks
cp -R vendor/mcoredev/tailor-blocks/dist/* public/assets/vendor/tailor-blocks/

Production integrations should normally load the published all-in-one bundle:

<link rel="stylesheet" href="/assets/vendor/tailor-blocks/tailor-blocks.min.css">
<script src="/assets/vendor/tailor-blocks/tailor-blocks.min.js"></script>

For debugging or split loading, the package also ships:

  • tailor-blocks-core.min.js
  • tailor-blocks-widgets.min.js
  • tailor-blocks-editor.min.js
  • tailor-blocks.js

The unminified split files are included for development and debugging.

Minimal PHP Usage

use TailorBlocks\Context\ContentContext;
use TailorBlocks\Editor\EditorMountOptions;
use TailorBlocks\EngineConfig;
use TailorBlocks\ProcessOptions;
use TailorBlocks\TailorBlocksEngine;

$engine = TailorBlocksEngine::createFromDirectory(
    __DIR__ . '/definitions',
    EngineConfig::builder()->build(),
);

$context = new ContentContext(
    siteKey: 'site-sk',
    permissions: ['content.edit'],
);

$editorConfig = $engine->editorConfig(
    $storedContent,
    $context,
    EditorMountOptions::default()
        ->withOutputSelector('#content_json')
        ->withDefaultCommandShortcuts(),
);

$processed = $engine->process(
    $submittedJson,
    $context,
    new ProcessOptions(strict: true, previousContent: $storedContent),
);

Minimal Browser Usage

<link rel="stylesheet" href="/assets/vendor/tailor-blocks/tailor-blocks.min.css">

<div id="tailor-editor"></div>
<textarea id="content_json" name="content_json" hidden></textarea>

<script src="/assets/vendor/tailor-blocks/tailor-blocks.min.js"></script>
<script>
  TailorBlocks.mount('#tailor-editor', editorConfig);
</script>

License

MIT