Download the PHP package mati365/ckeditor5-symfony without Composer
On this page you can find all versions of the php package mati365/ckeditor5-symfony. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mati365/ckeditor5-symfony
More information about mati365/ckeditor5-symfony
Files in mati365/ckeditor5-symfony
Package ckeditor5-symfony
Short Description CKEditor 5 integration for Symfony
License MIT
Informations about the package ckeditor5-symfony
ckeditor5-symfony
CKEditor 5 for Symfony >=6.4.x โ a lightweight WYSIWYG editor integration for Symfony. Easy to set up, it supports custom builds, dynamic loading, and localization. The package includes JavaScript and CSS assets, making it simple to integrate CKEditor 5 into your Symfony applications.
[!IMPORTANT] This integration is unofficial and not maintained by CKSource. For official CKEditor 5 documentation, visit ckeditor.com. If you encounter any issues in editor, please report them on the GitHub repository.
Table of Contents
- ckeditor5-symfony
- Table of Contents
- Compatibility ๐
- Installation ๐
- Usage ๐
- Editor Types ๐๏ธ
- Classic editor ๐
- Multiroot editor ๐ณ
- Inline editor ๐
- Balloon editor ๐
- Decoupled editor ๐
- Configuration โ๏ธ
- Custom Presets ๐งฉ
- Override configuration ๐ฏ
- Dynamic Presets ๐จ
- Providing the License Key ๐๏ธ
- Referencing DOM Elements in Config ๐ท๏ธ
- Localization ๐
- CDN Translation Loading ๐
- AssetsMapper local translations assignment ๐ฆ
- Global CDN translation loading โ๏ธ
- Global Translation Config ๐ ๏ธ
- AssetsMapper translations installation ๐ฅ
- Direct CDN translations configuration โ๏ธ
- Custom translations ๐
- Translation references in config ๐ค
- Paragraph-like editing ๐
- Classic / Balloon / Inline editor
- Decoupled editor
- Multiroot editor
- Forms Integration ๐งพ
- Editor roots change event ๐ก
- Custom plugins ๐งฉ
- Context ๐ค
- Basic usage ๐ง
- Custom context translations ๐
- Editors and Contexts registry ๐
- Installer command options โ๏ธ
- Development โ๏ธ
- Running Tests ๐งช
- Psst... ๐
- Trademarks ๐
- License ๐
Compatibility ๐
| CKEditor 5 Version | Integration Version |
|---|---|
| 43.x โ 47.x | <= 1.8.x |
| 48.x | 1.9.x - 1.10.x |
| >= 49.x | >= 1.11.x |
Installation ๐
-
Install the package:
-
Enable the bundle:
-
Run the installer:
Choose the distribution method that best fits your needs:
๐ Self-hosted via AssetsMapper (Recommended) Bundles assets locally. No Node.js required.
๐ฆ Self-hosted via Webpack Encore Requires Node.js and a bundler like Webpack Encore. Assets are bundled with your application.
and then add the following line to your main JavaScript file (e.g.,
assets/app.js):๐ก CDN Distribution Loads assets from CKSource CDN.
_For CDN, add
CKEDITOR5_LICENSE_KEY="your-key"to your.envfile._๐ก Tip: Add
--premiumto either command to install premium features (requires a valid license).For more options, see Installer command options.
Usage ๐
To use CKEditor 5 in your Twig templates, simply call the cke5_editor() function:
If you don't use AssetsMapper, and your distribution is set to cloud, make sure to include the assets using cke5_cloud_assets() in your <head> section.
Editor Types ๐๏ธ
CKEditor 5 Symfony supports four distinct editor types, each designed for specific use cases. Choose the one that best fits your application's layout and functionality requirements.
Classic editor ๐
Traditional WYSIWYG editor with a fixed toolbar above the editing area. Best for standard content editing scenarios like blog posts, articles, or forms.
Multiroot editor ๐ณ
Advanced editor supporting multiple independent editable areas within a single editor instance. Perfect for complex layouts like page builders, newsletters, or multi-section content management.
Inline editor ๐
Minimalist editor that appears directly within content when clicked. Ideal for in-place editing scenarios where the editing interface should be invisible until needed.
Note: Inline editors don't work with <textarea> elements and may not be suitable for traditional form scenarios.
Balloon editor ๐
Contextual editor that shows a floating toolbar when text is selected. Great for simple editing tasks where a full toolbar isn't necessary.
Decoupled editor ๐
Flexible editor where toolbar and editing area are completely separated. Provides maximum layout control for custom interfaces and complex applications.
Configuration โ๏ธ
You can configure the editor presets in your config/packages/ckeditor5.yaml file. The default preset is default, which provides a basic configuration with a toolbar and essential plugins. The preset is a map that contains the editor configuration, including the toolbar items and plugins. There can be multiple presets, and you can switch between them by passing the preset keyword argument to the cke5_editor function.
Custom Presets ๐งฉ
In order to override the default preset or add custom presets, you can add the following configuration:
In template:
The default one is specified here src/DependencyInjection/DefaultConfiguration.php.
Override configuration ๐ฏ
You can also override configuration at runtime by passing config or mergeConfig arguments to the editor function. This is useful if you want to change the editor configuration based on user input or other conditions.
Dynamic Presets ๐จ
For more complex scenarios, you can create preset configurations programmatically in your controller using PresetParser::parse(). This is useful when you need to build editor configurations based on user permissions, database settings, or other runtime conditions.
Then in your template, pass the preset object directly:
This approach gives you full control over editor configuration at runtime, allowing you to customize it based on application logic, user roles, or any other dynamic conditions.
Providing the License Key ๐๏ธ
CKEditor 5 requires a license key when using the official CDN or premium features. You can provide the license key in two simple ways:
- Environment variable: Set the
CKEDITOR5_LICENSE_KEYenvironment variable in your.envfile. This is the easiest and most common way. - Preset config: You can also set the license key directly in your preset configuration in
config/packages/ckeditor5.yaml:
If you use CKEditor 5 under the GPL license, you do not need to provide a license key. However, if you choose to set one, it must be set to GPL.
If both are set, the preset config takes priority. For more details, see the CKEditor 5 licensing guide.
Referencing DOM Elements in Config ๐ท๏ธ
You can reference DOM elements directly in your editor configuration using the special { $element: "selector" } format. This is useful when you want to attach the editor's UI parts (like toolbars or editable areas) to specific elements in your HTML.
This will find the elements with IDs my-toolbar and my-editable in the DOM and use them for the editor's UI.
โ ๏ธ If the element is not found, a warning will be shown in the console.
Localization ๐
Support multiple languages in the editor UI and content. Learn how to load translations via CDN or configure them globally.
CDN Translation Loading ๐
Depending on your setup, you can preload translations via CDN.
AssetsMapper local translations assignment ๐ฆ
If you want to load a specific language for the editor UI, you can specify the language argument in the cke5_editor() function:
Remember, that this only works if you have installed the translations using the ckeditor5:assets-mapper:install command with the --translations option.
Global CDN translation loading โ๏ธ
If you don't use AssetsMapper, you can load translations directly from CDN by specifying them in the preset config or during installation. See Global Translation Config for more details.
If you want to specify it in the template,you can use cke5_cloud_assets() function:
Global Translation Config ๐ ๏ธ
AssetsMapper translations installation ๐ฅ
You can fetch translations globally by specifying them in the ckeditor5:assets-mapper:install command:
Direct CDN translations configuration โ๏ธ
You can also configure translations globally in your configuration file. This is useful if you want to load translations for multiple languages at once or set a default language for the editor. Keep in mind that this configuration is only used when loading translations via CDN. If you are using self-hosted setup, translations are handled by your bundler automatically.
Note: For self-hosted setups, translations are handled by your bundler automatically.
Custom translations ๐
You can also provide custom translations for the editor. This is useful if you want to override existing translations or add new ones. Custom translations can be provided in the preset configuration.
Translation references in config ๐ค
You can also reference custom translations directly from your editor configuration by using
an object with a $translation key. When the editor is initialized the value will be
replaced with the correct string from the loaded translation packs (including any
customTranslations defined in your preset).
This is handy if you want to keep plugin labels or other strings inside the YAML and reuse them across presets or languages.
When the editor runs the { $translation: 'MyPluginLabel' } entry will be automatically
resolved to the appropriate string for the current UI language, so you donโt need to
hardโcode the text in multiple places.
Paragraph-like editing ๐
Paragraph-like editing mode restricts the editor's root to a single block element โ by default a <p> โ preventing users from inserting multiple top-level block elements (headings, lists, etc.). This is ideal for short-text fields such as article titles, captions, or descriptions: places where you want the richness of inline formatting (bold, italic, links) but a single-paragraph constraint.
The feature is enabled by passing model_element: '$inlineRoot' to the cke5_editor() or cke5_editable() Twig function. This maps the CKEditor 5 model root to the $inlineRoot schema element, which allows only inline content.
[!NOTE] Make sure your preset's toolbar and plugin list does not include block-level items (
Heading,List,BlockQuote, etc.) when usingmodel_element: '$inlineRoot', as those commands require block-level schema support that is absent in inline roots.
Classic / Balloon / Inline editor
For single-root editor types, pass model_element: '$inlineRoot' directly to cke5_editor():
The same parameter works with balloon and inline editor types:
If you reuse the inline-text pattern in many places, define a dedicated preset without block-level plugins and reference it by name:
Decoupled editor
For the decoupled editor, pass model_element: '$inlineRoot' to the cke5_editable() function rather than to cke5_editor(). Link the editable to the editor via editor_id:
Multiroot editor
In a multiroot setup each cke5_editable() can independently opt in to paragraph-like mode. Set model_element: '$inlineRoot' only on the roots that should be restricted; leave the others without it (they default to the standard $root):
When the editor initialises, each root whose model_element is set to '$inlineRoot' is registered under that schema element name. You can verify this at runtime via the JavaScript EditorsRegistry:
Forms Integration ๐งพ
Seamlessly integrate CKEditor 5 with Symfony Forms. The bundle provides a CKEditor5Type that facilitates easy integration. Use CKEditor5Type in your form class to render the editor.
Then in your template:
The editor automatically synchronizes its content with the underlying hidden input field upon form submission.
Editor roots change event ๐ก
Each editor dispatches a custom ckeditor5:change:data when any of its roots' data changes. This event includes the editor's ID, the editor instance, and the current data of all roots, allowing you to react to content changes in real time. It's safer to mount your listeners on the document.body to ensure they are registered to avoid issues with race conditions during editor initialization.
Custom plugins ๐งฉ
To register a custom plugin, use the CustomEditorPluginsRegistry.
In order to use the plugin you need to extend your config in config/packages/ckeditor5.yaml:
It must be called before the editor is initialized. You can unregister the plugin later by calling the returned function:
If you want to de-register all registered plugins, you can use the unregisterAll method:
Context ๐ค
The context feature is designed to group multiple editor instances together, allowing them to share a common context. This is particularly useful in collaborative editing scenarios, where users can work together in real time. By sharing a context, editors can synchronize features such as comments, track changes, and presence indicators across different editor instances. This enables seamless collaboration and advanced workflows in your application.
For more information about the context feature, see the CKEditor 5 Context documentation.
Basic usage ๐ง
Define your context in configuration:
And use it in your template:
Voila!
Custom context translations ๐
Define your custom translations in the configuration:
These translations will be used in the context's editors, overriding the default translations. They are available through locale.t plugin in every context plugin.
Editors and Contexts registry ๐
The package provides two registries: EditorsRegistry and ContextsRegistry. They allow you to watch for changes in registered editors and contexts, get instances directly, or execute logic when a specific editor or context appears.
-
mountEffect(id, callback)โ executes logic whenever the editor is initialized or restarted. This is the recommended way to implement integrations that must be re-initialized throughout the editor's lifecycle. -
watch(callback)โ react whenever registry state changes. -
waitFor(id)โ get the instance directly. If it is already registered, the promise resolves immediately. -
execute(id, callback)โ run logic immediately if the instance already exists, or later when it appears. - The same methods are available on
ContextsRegistryfor shared contexts:
Installer command options โ๏ธ
The ckeditor5:assets-mapper:install command supports the following options:
Development โ๏ธ
To start the development environment, run:
The playground app will be available at http://localhost:8000.
Running Tests ๐งช
The project includes comprehensive PHP unit tests with 100% code coverage requirement:
Psst... ๐
If you're looking for similar stuff, check these out:
-
ckeditor5-livewire Effortless CKEditor 5 integration for Laravel Livewire. Supports dynamic content, localization, and custom builds with minimal setup.
-
ckeditor5-phoenix Seamless CKEditor 5 integration for Phoenix Framework. Plug & play support for LiveView forms with dynamic content, localization, and custom builds.
- ckeditor5-rails Smooth CKEditor 5 integration for Ruby on Rails. Works with standard forms, Turbo, and Hotwire. Easy setup, custom builds, and localization support.
Trademarks ๐
CKEditorยฎ is a trademark of CKSource Holding sp. z o.o. All rights reserved. For more information about the license of CKEditorยฎ please visit CKEditor's licensing page.
This package is not owned by CKSource and does not use the CKEditorยฎ trademark for commercial purposes. It should not be associated with or considered an official CKSource product.
License ๐
This project is licensed under the terms of the MIT LICENSE.
This project injects CKEditor 5 which is licensed under the terms of GNU General Public License Version 2 or later. For more information about CKEditor 5 licensing, please see their official documentation.
All versions of ckeditor5-symfony with dependencies
twig/twig Version ^3.0
symfony/asset Version ^6.4|^7.0|^8.0
symfony/console Version ^6.4|^7.0|^8.0
symfony/http-foundation Version ^6.4|^7.0|^8.0
symfony/http-kernel Version ^6.4|^7.0|^8.0
symfony/http-client Version ^6.4|^7.0|^8.0
symfony/form Version ^6.4|^7.0|^8.0
symfony/dependency-injection Version ^6.4|^7.0|^8.0