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

Core Bundle Laravel Package

symfony-cmf/core-bundle

Symfony CMF Core Bundle provides shared infrastructure for CMF bundles: base classes, helpers, configuration and integration glue for Symfony projects. Supports content repositories (e.g., PHPCR), routing, and common services to build content-managed sites.

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation

    composer require symfony-cmf/core-bundle
    

    Add to config/bundles.php:

    return [
        // ...
        SymfonyCmf\Bundle\CoreBundle\SymfonyCmfCoreBundle::class => ['all' => true],
    ];
    
  2. First Use Case: Rendering a Content Document Inject the ContentResolverInterface and ContentFactoryInterface into a controller or service:

    use SymfonyCmf\Bundle\CoreBundle\Resolver\ContentResolverInterface;
    use SymfonyCmf\Bundle\CoreBundle\Factory\ContentFactoryInterface;
    
    public function __construct(
        private ContentResolverInterface $contentResolver,
        private ContentFactoryInterface $contentFactory
    ) {}
    
    public function showDocument(Document $document)
    {
        $resolvedContent = $this->contentResolver->resolve($document);
        return $this->render('document/show.html.twig', [
            'content' => $resolvedContent,
        ]);
    }
    
  3. Key Classes to Explore

    • ContentResolverInterface: Resolves documents to renderable content.
    • ContentFactoryInterface: Creates new content instances.
    • Content and Document entities (check src/Entity/ in the bundle).

Implementation Patterns

Workflow: Content Rendering Pipeline

  1. Resolve Content Use ContentResolver to fetch and resolve a document:

    $content = $this->contentResolver->resolve($document);
    
    • Supports lazy-loading and caching (configure via cmf_core.yaml).
  2. Modify Content (Pre-Render) Extend or wrap the resolver to add logic:

    $content->setProperty('custom_field', $value); // If using Doctrine extensions
    
  3. Render with Twig Access properties via Twig:

    {{ content.title }}
    {{ content.body|raw }}
    

Integration with Doctrine

  • Use SymfonyCmf\Bundle\CoreBundle\Doctrine\Phpcr\DocumentManager for PHPCR (if installed).
  • For Doctrine ORM, extend Content and map to your entities:
    # config/doctrine/orm/Entity/YourContent.orm.yml
    SymfonyCmf\Bundle\CoreBundle\Model\Content:
        inheritanceType: JOINED
        table: your_content
        fields:
            title: ~
    

Event-Driven Extensions

Listen to cmf.content.pre_resolve or cmf.content.post_resolve events:

// src/EventListener/CustomContentListener.php
public function onPreResolve(ContentEvent $event)
{
    $content = $event->getContent();
    if ($content->getType() === 'page') {
        $content->setProperty('meta_tags', $this->generateMetaTags());
    }
}

Gotchas and Tips

Pitfalls

  1. PHPCR vs. Doctrine ORM

    • The bundle defaults to PHPCR (PHPCR-ODM). For Doctrine ORM, install symfony-cmf/doctrine-orm-bundle and configure cmf_core.yaml:
      cmf_core:
          document_manager: doctrine_orm
      
  2. Caching Quirks

    • Resolved content is cached by default. Clear cache after modifying resolvers:
      php bin/console cache:clear
      
  3. Content Type Mismatches

    • Ensure your Content entity extends SymfonyCmf\Bundle\CoreBundle\Model\Content and is mapped correctly. Use:
      php bin/console debug:cmf:content-types
      

Debugging Tips

  • Dump Resolved Content
    dump($this->contentResolver->resolve($document));
    
  • Check Resolver Chain Inspect active resolvers in cmf_core.yaml under resolver.chain.

Extension Points

  1. Custom Resolvers Implement ResolverInterface and register in services.yaml:

    services:
        App\Resolver\CustomResolver:
            tags:
                - { name: 'cmf.resolver', priority: 10 }
    
  2. Override Content Factory Extend ContentFactory and bind it in DI:

    // src/Factory/CustomContentFactory.php
    class CustomContentFactory extends ContentFactory {}
    
    services:
        SymfonyCmf\Bundle\CoreBundle\Factory\ContentFactory:
            alias: App\Factory\CustomContentFactory
    
  3. Twig Extensions Add custom filters/filters to resources/config/twig.yaml:

    twig:
        globals:
            cmf_content_helper: '@SymfonyCmf\Bundle\CoreBundle\Twig\ContentExtension'
    
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.
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
spatie/laravel-javascript-views