Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Create Bundle Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. 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>
    
  2. Enable Bundle: Add to config/bundles.php:

    return [
        // ...
        SymfonyCmf\Bundle\CreateBundle\CreateBundle::class => ['all' => true],
    ];
    
  3. Basic Configuration: In config/packages/symfony_cmf_create.yaml:

    symfony_cmf_create:
        create_js:
            enabled: true
            version: '1.0.0'
        createphp:
            enabled: true
    
  4. 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>
    

Implementation Patterns

Core Workflows

  1. RDFa Annotation:

    • Use 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 {}
      
    • Render annotations in Twig:
      {{ dump(app.createphp.rdfaRenderer.render(page)) }}
      
  2. Frontend Integration:

    • Initialize create.js in a Twig block:
      {# app/Resources/views/base.html.twig #}
      {{ parent() }}
      {{ include('CreateBundle::createjs.html.twig') }}
      
    • Configure editable regions via data-* attributes:
      <div data-createjs="true" data-createjs-type="text"></div>
      
  3. Saving Edits:

    • Use Symfony’s form system to handle submissions:
      // 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());
          }
      }
      
  4. Custom Workflows:

    • Extend 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)
          }
      }
      
    • Register in config:
      symfony_cmf_create:
          workflows:
              custom: App\Workflow\CustomCreateWorkflow
      

Gotchas and Tips

Pitfalls

  1. Unmaintained Status:

    • Avoid relying on new features; focus on existing functionality (e.g., RDFa rendering, create.js integration).
    • Monitor GitHub issues for security fixes or community-driven updates.
  2. Doctrine ORM Dependency:

    • If not using Doctrine, manually implement CreatePhp\Annotation\AnnotationReader for custom ORMs.
  3. JavaScript Conflicts:

    • Ensure 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'}) }}
      
  4. RDFa Validation:

    • Use the W3C RDFa Validator to debug annotations:
      curl -X POST --data-urlencode "document=<YOUR_HTML>" https://www.w3.org/RDFa/validator
      

Debugging Tips

  1. Enable Verbose Logging:

    # config/packages/monolog.yaml
    handlers:
        main:
            level: debug
            channels: ['symfony_cmf_create']
    
  2. Check create.js Console:

    • Inspect browser console for errors (e.g., missing data-createjs attributes or jQuery conflicts).
  3. Test RDFa Rendering:

    • Temporarily output raw RDFa in Twig to verify annotations:
      {{ app.createphp.rdfaRenderer.render(page) }}
      

Extension Points

  1. Custom RDFa Vocabularies:

    • Extend CreatePhp\Annotation\AnnotationReader to support custom RDFa predicates:
      class CustomAnnotationReader extends AnnotationReader
      {
          public function getCustomVocabulary()
          {
              return ['custom:predicate' => 'http://example.com/ns#predicate'];
          }
      }
      
    • Register as a service:
      services:
          app.createphp.annotation_reader:
              class: App\CreatePhp\CustomAnnotationReader
              tags: ['symfony_cmf_create.annotation_reader']
      
  2. Post-Save Hooks:

    • Use Symfony’s event system to trigger actions after 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
          }
      }
      
  3. Asset Management:

    • Override create.js version or path in config:
      symfony_cmf_create:
          create_js:
              version: '1.0.0'
              path: '/custom/path/to/create.min.js'
      
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky
spatie/mailcoach-vapor