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

Content Bundle Laravel Package

bigfoot/content-bundle

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation Add the package via Composer:

    composer require bigfoot/content-bundle:dev-master
    

    Register the bundle in app/AppKernel.php:

    new Bigfoot\Bundle\ContentBundle\BigfootContentBundle(),
    
  2. Basic Configuration Define widgets in app/config/config.yml:

    bigfoot_content:
        widgets:
            dashboard_header: 'AppBundle\Widget\DashboardHeaderWidget'
    
  3. First Widget Create a widget class extending AbstractWidget:

    namespace AppBundle\Widget;
    use Bigfoot\Bundle\ContentBundle\Model\AbstractWidget;
    
    class DashboardHeaderWidget extends AbstractWidget {
        public function getName() { return 'dashboard_header'; }
        public function render() { return '<h1>Welcome!</h1>'; }
    }
    
  4. Accessing Pages/Static Content Use the admin interface (if available) or manually create entities via Doctrine:

    php app/console doctrine:generate:entities Bigfoot\Bundle\ContentBundle\Entity
    

Implementation Patterns

Widget Development

  1. Extending AbstractWidget Implement required methods:

    class MyWidget extends AbstractWidget {
        public function getName() { /* Unique slug */ }
        public function render() { /* HTML output */ }
        public function getTitle() { /* Display title */ }
    }
    
  2. Dynamic Content Fetch data via services or repositories:

    public function render() {
        $hotels = $this->get('hotel.repository')->findMostViewed();
        return $this->renderView('widgets/most_viewed.html.twig', ['hotels' => $hotels]);
    }
    
  3. Twig Integration Use Twig templates for complex widgets:

    public function render() {
        return $this->renderView('AppBundle:Widget:my_widget.html.twig');
    }
    

Page Management

  1. Hierarchical Pages Define parent-child relationships in the admin panel or via fixtures:

    # app/fixtures/pages.yml
    AppBundle\Entity\Page:
        page_home:
            title: Home
            slug: home
            parent: ~
        page_about:
            title: About
            slug: about
            parent: @page_home
    
  2. Static Content Blocks Store reusable content snippets (e.g., FAQs, policies) and reference them in pages:

    // In a controller
    $staticContent = $this->get('bigfoot_content.static_content.manager')->findBySlug('privacy_policy');
    

Dashboard Integration

  1. Widget Placement Configure widget positions in config.yml:

    bigfoot_content:
        dashboard:
            columns: 3
            widgets:
                - { name: dashboard_header, position: 1 }
                - { name: widget_most_viewed_hotel, position: 2 }
    
  2. Admin Panel Usage Use the built-in admin interface (if enabled) to:

    • Drag-and-drop widgets.
    • Edit static content.
    • Manage page hierarchies.

Gotchas and Tips

Common Pitfalls

  1. Widget Registration

    • Issue: Widgets not appearing in the dashboard.
    • Fix: Ensure the widget class is:
      • Properly namespaced.
      • Extends AbstractWidget.
      • Registered in config.yml with the exact class name (including namespace).
      • The getName() method returns a unique slug (case-sensitive).
  2. Outdated Doctrine Entities

    • Issue: Page or StaticContent entities not found.
    • Fix: Regenerate entities after updates:
      php app/console doctrine:generate:entities Bigfoot\Bundle\ContentBundle\Entity
      php app/console doctrine:schema:update --force
      
  3. Twig Template Paths

    • Issue: renderView() fails with "template not found."
    • Fix: Use fully qualified paths:
      $this->renderView('@AppBundle/Widget/my_widget.html.twig');
      
  4. Caching Headaches

    • Issue: Widgets not updating immediately.
    • Fix: Clear the cache after changes:
      php app/console cache:clear
      

Debugging Tips

  1. Widget Debugging Add a debug() method to your widget:

    public function debug() {
        return [
            'name' => $this->getName(),
            'config' => $this->getConfig(),
        ];
    }
    

    Call it via a route to inspect state.

  2. Database Inspection Check raw data in the bigfoot_content_widget, bigfoot_content_page, and bigfoot_content_static_content tables:

    php app/console doctrine:query:sql "SELECT * FROM bigfoot_content_widget"
    
  3. Event Listeners Override widget/static content events in your bundle’s Resources/config/services.yml:

    services:
        app.widget.listener:
            class: AppBundle\EventListener\WidgetListener
            tags:
                - { name: kernel.event_listener, event: bigfoot.content.widget.save, method: onWidgetSave }
    

Extension Points

  1. Custom Widget Types Extend AbstractWidget to add fields (e.g., setConfig(), getConfig()):

    class ConfigurableWidget extends AbstractWidget {
        protected $config = ['title' => 'Default'];
    
        public function setConfig(array $config) { $this->config = $config; }
        public function getConfig() { return $this->config; }
    }
    
  2. Admin Panel Customization Override the admin templates in app/Resources/BigfootContentBundle/views/ to modify:

    • Widget edit forms.
    • Page management UIs.
    • Static content interfaces.
  3. API Integration Expose widgets via a custom API endpoint:

    // src/AppBundle/Controller/WidgetController.php
    class WidgetController extends Controller {
        public function getDashboardWidgetsAction() {
            $widgets = $this->get('bigfoot_content.widget.manager')->getDashboardWidgets();
            return $this->json($widgets);
        }
    }
    

Configuration Quirks

  1. Widget Positions

    • Positions are 1-indexed (not 0-indexed).
    • Gaps in numbering (e.g., positions 1, 3) are allowed but may cause UI misalignment.
  2. Static Content Slugs

    • Slugs are case-sensitive and must match exactly when fetching:
      $content = $this->get('bigfoot_content.static_content.manager')->findBySlug('PrivacyPolicy'); // Fails
      $content = $this->get('bigfoot_content.static_content.manager')->findBySlug('privacy_policy'); // Works
      
  3. Dependency Injection

    • Use the WidgetContext service for shared data:
      $this->get('bigfoot_content.widget.context')->set('user', $user);
      
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.
craftcms/url-validator
directorytree/privacy-filter-classifier
directorytree/privacy-filter
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata
splash/openapi
splash/scopes
splash/toolkit
testo/output-teamcity
testo/bridge-symfony