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

Symfonycms Laravel Package

brangerieau/symfonycms

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup for Laravel Integration (via Symfony Bridge)

Since this is a Symfony bundle, Laravel developers will need to use Symfony’s Laravel Bridge (symfony/ux-live-component + symfony/ux-turbo) or a standalone Symfony microkernel for seamless integration. Start here:

  1. Install Symfony Bridge (Recommended)

    composer require symfony/ux-live-component symfony/ux-turbo
    

    Configure Live Components in resources/views/layouts/app.blade.php:

    <html data-turbo="true">
    <body>
        {{ $slot }}
        @livewireScripts
        @symfonyUxScripts
    </body>
    </html>
    
  2. Install the Bundle via Composer

    composer require brangerieau/symfonycms
    
  3. Create a Symfony Kernel (Optional but Recommended) Use symfony/var-dumper and symfony/http-kernel to embed Symfony routes in Laravel:

    // app/Providers/SymfonyKernelServiceProvider.php
    use Symfony\Component\HttpKernel\KernelInterface;
    use Brangerieau\SymfonyCmsBundle\SymfonyCmsBundle;
    
    class SymfonyKernelServiceProvider extends ServiceProvider
    {
        public function register()
        {
            $kernel = new class extends \Symfony\Component\HttpKernel\Kernel {
                public function registerBundles(): array
                {
                    return [
                        new SymfonyCmsBundle(),
                    ];
                }
            };
            $this->app->singleton(KernelInterface::class, fn() => $kernel);
        }
    }
    
  4. Route the Admin Panel Add Symfony routes to Laravel’s routes/web.php:

    Route::prefix('admin')->group(function () {
        Route::get('/{path}', function () {
            $kernel = app(KernelInterface::class);
            return $kernel->handle(
                Request::create('/admin/' . $path, 'GET')
            );
        });
    });
    
  5. Install Assets

    php artisan symfony:assets:install  # Hypothetical; check bundle docs
    npm run dev  # If using Webpack Encore
    

First Use Case: Quick CMS Page Creation

  1. Create a Content Type Define a new content type in config/packages/symfony_cms.yaml:
    brangerieau_symfony_cms:
        content_types:
            blog_post:
                fields:
                    - { name: 'title', type: 'text' }
                    - { name: 'body', type: 'html' }
    
  2. Generate a CRUD Interface The bundle auto-generates an admin panel at /admin/content/blog_post. Use it to:
    • Create/edit content.
    • Assign roles (e.g., ROLE_CMS_EDITOR) via Symfony’s security system.

Implementation Patterns

Workflow: Decoupled Frontend + Symfony CMS

  1. Laravel as API + Symfony as CMS

    • Use Laravel’s API routes for business logic.
    • Offload content management to SymfonyCMS.
    • Fetch CMS content via Symfony’s HTTP client:
      $response = Http::withOptions(['verify' => false])->get('http://symfony-cms/admin/api/content');
      
  2. Livewire + Symfony CMS Integration

    • Use Livewire for reactive frontend forms.
    • Proxy Symfony CMS data to Livewire components:
      // app/Http/Livewire/CmsContentManager.php
      public function getContent($type)
      {
          return Http::get("/admin/api/content/{$type}")->json();
      }
      
  3. Twig Templates in Laravel (Advanced)

    • Embed Twig templates in Laravel using twig/extra-bundle:
      $loader = new \Twig\Loader\FilesystemLoader(__DIR__.'/resources/views');
      $twig = new \Twig\Environment($loader);
      echo $twig->render('cms_template.html.twig', ['content' => $data]);
      

Integration Tips

  • Authentication: Sync Laravel users to Symfony’s security system via UserProvider:
    // config/packages/security.yaml (Symfony side)
    providers:
        laravel_users:
            entity: { class: App\Models\User, property: email }
    
  • Database: Use a shared Doctrine DB or separate databases with doctrine/dbal.
  • Assets: Override Symfony’s Webpack Encore config in webpack.config.js to match Laravel’s setup.

Gotchas and Tips

Pitfalls

  1. Symfony vs. Laravel Routing Conflicts

    • Symfony routes take precedence. Use Laravel’s Route::prefix('admin') to isolate Symfony routes.
    • Fix: Clear Laravel’s route cache (php artisan route:clear) after changes.
  2. Asset Pipeline Mismatch

    • Symfony’s Webpack Encore may conflict with Laravel Mix.
    • Fix: Disable Symfony’s Encore in config/packages/webpack_encore.yaml and use Laravel Mix instead.
  3. Doctrine ORM vs. Eloquent

    • SymfonyCMS uses Doctrine. Avoid mixing Eloquent and Doctrine models in the same transaction.
    • Fix: Use a separate database for Symfony or abstract models via repositories.
  4. Security Misconfigurations

    • Symfony’s security.yaml is not auto-loaded in Laravel.
    • Fix: Manually merge security configurations:
      # config/auth.php (Laravel)
      'providers' => [
          'symfony' => [
              'driver' => 'symfony',
              'model' => Brangerieau\SymfonyCmsBundle\Entity\User::class,
          ],
      ],
      

Debugging Tips

  1. Symfony Kernel Debugging
    • Dump the Symfony kernel’s environment:
      dd(app(KernelInterface::class)->getEnvironment());
      
  2. Route Debugging
    • List Symfony routes:
      php artisan symfony:debug:routes  # Hypothetical; use Symfony’s `debug:router` instead
      
  3. Doctrine Queries
    • Enable Doctrine profiling in config/packages/doctrine.yaml:
      doctrine:
          dbal:
              profiling: '%kernel.debug%'
      

Extension Points

  1. Custom Content Types Extend the bundle’s content type system by creating a custom field type:

    // src/FieldType/CustomFieldType.php
    namespace App\FieldType;
    use Brangerieau\SymfonyCmsBundle\Form\FieldType\AbstractFieldType;
    
    class CustomFieldType extends AbstractFieldType
    {
        public function getType(): string { return 'custom'; }
        public function buildForm(FormBuilderInterface $builder, array $options) { /* ... */ }
    }
    

    Register in config/packages/symfony_cms.yaml:

    brangerieau_symfony_cms:
        field_types:
            custom: App\FieldType\CustomFieldType
    
  2. Event Listeners Hook into SymfonyCMS events (e.g., content.pre_save):

    // src/EventListener/CmsListener.php
    namespace App\EventListener;
    use Brangerieau\SymfonyCmsBundle\Event\ContentEvent;
    
    class CmsListener
    {
        public function onContentSave(ContentEvent $event)
        {
            $content = $event->getContent();
            // Modify content before save
        }
    }
    

    Register in config/services.yaml:

    services:
        App\EventListener\CmsListener:
            tags:
                - { name: 'kernel.event_listener', event: 'content.pre_save' }
    
  3. Override Twig Templates Copy SymfonyCMS templates from vendor/brangerieau/symfonycms/src/Resources/views to resources/views/symfony_cms to override them.


Performance Quirks

  • Caching: SymfonyCMS uses its own cache system. Clear it with:
    php artisan cache:clear  # Laravel
    php bin/console cache:clear  # Symfony (if embedded)
    
  • Database Indexes: Add indexes to cms_content table for large datasets:
    CREATE INDEX idx_content_type ON cms_content(type);
    
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.
emuniq/filament-browser-notifications
syriable/filament-translator
hungnm28/livewire-form
wenprise/eloquent
crudly/encrypted
fadion/bouncy
cuci/prototurk-sdk
gos/pubsub-router-bundle
cuci/prototurk-sdk-symfony
clementtalleu/easyadmin-markdown-bundle
codeflextech/permission-manager
karnoweb/livewire-datepicker
sayedenam/sayed-dashboard
milito/query-filter
apiboxsym/user-bundle
apiboxsym/health-check-bundle
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui