symfony-cmf/create-bundle
Symfony CMF CreateBundle integrates create.js and the CreatePHP helper into Symfony 2.8+ for in-place front-end editing using RDFa annotations. Part of Symfony CMF. Unmaintained; only security and submitted bug fixes are released.
Installation:
composer require symfony-cmf/create-bundle
Ensure create.js is included via the bundle’s post-install task or manually via CDN:
<script src="https://cdnjs.cloudflare.com/ajax/libs/createjs/1.0.0/create.min.js"></script>
Enable Bundle:
Add to config/bundles.php:
return [
// ...
SymfonyCmf\Bundle\CreateBundle\CreateBundle::class => ['all' => true],
];
Basic Configuration:
In config/packages/symfony_cmf_create.yaml:
symfony_cmf_create:
create_js:
enabled: true
version: '1.0.0'
createphp:
enabled: true
First Use Case:
Annotate a Twig template with RDFa (e.g., app/Resources/views/base.html.twig):
<div about="{{ page.uri }}" typeof="foaf:Document">
<h1 property="dc:title">{{ page.title }}</h1>
<div property="content" contenteditable="true" data-createjs="true">
{{ page.body }}
</div>
</div>
RDFa Annotation:
CreatePHP to dynamically annotate entities (e.g., Doctrine models) with RDFa:
use SymfonyCmf\CreateBundle\CreatePhp\Annotation\Rdfa;
/**
* @Rdfa\About("/articles/{id}")
* @Rdfa\Type("foaf:Document")
*/
class Article {}
{{ dump(app.createphp.rdfaRenderer.render(page)) }}
Frontend Integration:
create.js in a Twig block:
{# app/Resources/views/base.html.twig #}
{{ parent() }}
{{ include('CreateBundle::createjs.html.twig') }}
data-* attributes:
<div data-createjs="true" data-createjs-type="text"></div>
Saving Edits:
// src/Controller/ArticleController.php
public function update(Article $article, Request $request)
{
$form = $this->createForm(ArticleType::class, $article);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$em->flush();
return new RedirectResponse($article->getUri());
}
}
Custom Workflows:
CreateWorkflow to handle custom logic (e.g., validation):
use SymfonyCmf\CreateBundle\Workflow\CreateWorkflowInterface;
class CustomCreateWorkflow implements CreateWorkflowInterface
{
public function preSave($entity, $data)
{
// Custom logic (e.g., sanitize input)
}
}
symfony_cmf_create:
workflows:
custom: App\Workflow\CustomCreateWorkflow
Unmaintained Status:
create.js integration).Doctrine ORM Dependency:
CreatePhp\Annotation\AnnotationReader for custom ORMs.JavaScript Conflicts:
create.js loads after jQuery (required for some plugins):
{{ include('CreateBundle::createjs.html.twig', {'jquery': 'https://code.jquery.com/jquery-3.6.0.min.js'}) }}
RDFa Validation:
curl -X POST --data-urlencode "document=<YOUR_HTML>" https://www.w3.org/RDFa/validator
Enable Verbose Logging:
# config/packages/monolog.yaml
handlers:
main:
level: debug
channels: ['symfony_cmf_create']
Check create.js Console:
data-createjs attributes or jQuery conflicts).Test RDFa Rendering:
{{ app.createphp.rdfaRenderer.render(page) }}
Custom RDFa Vocabularies:
CreatePhp\Annotation\AnnotationReader to support custom RDFa predicates:
class CustomAnnotationReader extends AnnotationReader
{
public function getCustomVocabulary()
{
return ['custom:predicate' => 'http://example.com/ns#predicate'];
}
}
services:
app.createphp.annotation_reader:
class: App\CreatePhp\CustomAnnotationReader
tags: ['symfony_cmf_create.annotation_reader']
Post-Save Hooks:
create.js saves:
// src/EventSubscriber/CreateSaveSubscriber.php
class CreateSaveSubscriber implements EventSubscriberInterface
{
public static function getSubscribedEvents()
{
return [
CreateEvents::POST_SAVE => 'onPostSave',
];
}
public function onPostSave(CreateEvent $event)
{
// E.g., send notification, update search index
}
}
Asset Management:
create.js version or path in config:
symfony_cmf_create:
create_js:
version: '1.0.0'
path: '/custom/path/to/create.min.js'
How can I help you explore Laravel packages today?