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

Simple Cms Bundle Laravel Package

symfony-cmf/simple-cms-bundle

Symfony CMF Simple CMS Bundle maps content, routes, and menu items from a single tree in a content repository, prioritizing simplicity over flexibility. Part of Symfony CMF. Unmaintained; only security and bugfix releases expected.

View on GitHub
Deep Wiki
Context7

Getting Started

First Steps

  1. Installation Add the bundle to your composer.json:

    composer require symfony-cmf/simple-cms-bundle
    

    Register it in config/bundles.php:

    return [
        // ...
        SymfonyCmf\SimpleCmsBundle\SimpleCmsBundle::class => ['all' => true],
    ];
    
  2. Database Setup Run migrations (if provided in the bundle or create your own):

    php bin/console doctrine:migrations:diff
    php bin/console doctrine:migrations:migrate
    
  3. Basic Configuration Update config/packages/simple_cms.yaml (if it exists) or create it:

    simple_cms:
        routes:
            enabled: true
        content:
            enabled: true
    
  4. First Use Case Create a simple route-based page:

    php bin/console simple-cms:create-route --name="homepage" --path="/"
    

    Then create a controller to handle it (if not auto-generated).


Implementation Patterns

Core Workflows

  1. Route-Based CMS

    • Define routes dynamically via the CLI or admin panel:
      php bin/console simple-cms:create-route --name="about" --path="/about"
      
    • Use annotations or YAML to map routes to controllers:
      # config/routes/simple_cms.yaml
      simple_cms_route:
          resource: "@SimpleCmsBundle/Resources/config/routing.yml"
          prefix: /
      
  2. Content Management

    • Store content in Doctrine entities (extend SimpleCmsBundle\Model\Content):
      namespace App\Entity;
      
      use SymfonyCmf\SimpleCmsBundle\Model\Content as BaseContent;
      
      class Page extends BaseContent {
          // Custom fields
      }
      
    • Use the ContentRepository to fetch/publish content:
      $content = $this->getDoctrine()->getRepository(Page::class)->findOneBy(['route' => '/']);
      
  3. Twig Integration

    • Access content in templates:
      {% set content = app.simple_cms.content_manager.getContent('/') %}
      {{ content.title }}
      
    • Override templates in templates/SimpleCmsBundle/ (e.g., default.html.twig).
  4. Versioning & Publishing

    • Use the ContentManager to publish drafts:
      $content->setPublished(true);
      $contentManager->publish($content);
      

Integration Tips

  • Symfony Flex: If using Symfony 4+, manually configure bundles in config/bundles.php.
  • Doctrine: Ensure your entities extend the bundle’s base models (Content, Route).
  • Routing: Prefer YAML/annotation-based routes over CLI for maintainability.
  • Events: Listen to simple_cms.content.pre_publish or simple_cms.route.create for custom logic.

Gotchas and Tips

Pitfalls

  1. Unmaintained Status

    • Expect no updates; fork or patch locally if needed.
    • Avoid relying on undocumented features (e.g., newer Symfony versions may break compatibility).
  2. Route Conflicts

    • SimpleCMS routes may clash with Symfony’s router. Use priorities or prefixes:
      simple_cms_route:
          resource: "@SimpleCmsBundle/Resources/config/routing.yml"
          prefix: /cms
      
  3. Doctrine Migrations

    • The bundle lacks built-in migrations. Create your own for custom fields:
      php bin/console make:migration
      
  4. Caching Quirks

    • Clear cache after publishing content:
      php bin/console cache:clear
      
    • Override SimpleCmsBundle\Twig\Extension\ContentExtension to customize caching behavior.

Debugging Tips

  • Route Debugging: Use php bin/console debug:router to inspect registered routes.
  • Content Debugging: Dump content objects to verify fields:
    dump($content->getRoute()->getPath());
    
  • Event Debugging: Subscribe to events to log actions:
    $eventDispatcher->addListener('simple_cms.content.pre_publish', function ($event) {
        error_log('Publishing: ' . $event->getContent()->getRoute());
    });
    

Extension Points

  1. Custom Content Types Extend BaseContent and register the entity in config/doctrine.yaml:

    App\Entity\Page:
        type: entity
        repositoryClass: App\Repository\PageRepository
    
  2. Route Providers Implement SymfonyCmf\SimpleCmsBundle\Provider\RouteProviderInterface for dynamic routes.

  3. Twig Extensions Override the ContentExtension to add custom filters/functions:

    class CustomContentExtension extends \SymfonyCmf\SimpleCmsBundle\Twig\Extension\ContentExtension {
        public function getMarkup($content) {
            return "Custom: " . $content->getTitle();
        }
    }
    

    Register it in services.yaml:

    app.twig.extension.content:
        class: App\Twig\Extension\CustomContentExtension
        tags: ['twig.extension']
    
  4. CLI Commands Extend SimpleCmsBundle\Command\AbstractCommand to add custom commands.

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.
terminal42/code-quality-tools
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