PHP & Laravel

Back to Home

Using Lilac from PHP

Lilac's core runs in the browser, so the PHP package renders the markup that mounts it: a container plus a script that loads the published UMD build from a CDN. Works in plain PHP, or as a Laravel Blade component.

Installation

# Composer (Packagist)
composer require lilac-wysiwyg/lilac

Plain PHP

use Lilac\Editor;

echo Editor::render([
  'toolbar' => ['show' => true],
  'placeholder' => 'Start writing…',
  'theme' => 'auto',
  'initialContent' => '<p>Hello from PHP!</p>',
]);

Laravel

{{-- The service provider is auto-discovered; just use the component --}}
<x-lilac
  :value="old('body', $post->body)"
  placeholder="Write your post…"
  theme="auto"
/>

Just a script tag

<!-- Load the UMD build once, then construct editors yourself -->
echo Lilac\Editor::scriptTag(); // or a pinned version: scriptTag('0.7.1')

<div id="editor"></div>
<script>
  new window.Lilac.LilacEditor({ container: document.getElementById('editor'), toolbar: { show: true } });
</script>

Features

Framework-free

Lilac\Editor::render() returns an HTML string — drop it into any PHP template.

Laravel Blade

An auto-discovered <x-lilac /> component, no manual provider registration.

CDN-loaded core

Pulls the published window.Lilac UMD build; pin a version or track the latest.

One shared loader

Multiple editors on a page reuse a single script include.

Live Playground

This page is static, so the PHP is shown rather than executed (v0.6.0). The rendered output is a plain editor identical to every other integration.

PHP & Laravel v0.6.0