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

Sulu Page Export Laravel Package

comsa/sulu-page-export

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation

    composer require comsa/sulu-page-export
    

    Ensure your project uses Sulu CMS (v2.x recommended) and follows its standard structure.

  2. Configuration Add the bundle to config/bundles.php:

    Comsa\SuluPageExport\SuluPageExportBundle::class => ['all' => true],
    
  3. First Use Case Trigger an export via CLI:

    php bin/console sulu:page-export:export --page-id=1 --format=html
    

    Outputs exported content to var/exports/page-1.html.


Implementation Patterns

Common Workflows

  1. Admin UI Integration Extend Sulu’s admin panel with a custom button:

    // src/EventListener/AddExportButtonListener.php
    use Comsa\SuluPageExport\Event\ExportButtonEvent;
    
    class AddExportButtonListener
    {
        public function onExportButton(ExportButtonEvent $event)
        {
            $event->addButton('export', 'Export Page', 'fas fa-file-export');
        }
    }
    

    Register in services.yaml:

    services:
        App\EventListener\AddExportButtonListener:
            tags:
                - { name: kernel.event_listener, event: sulu_page_export.export_button, method: onExportButton }
    
  2. Scheduled Exports Use Symfony’s cron or a task scheduler:

    # config/packages/sulu_page_export.yaml
    sulu_page_export:
        scheduled_exports:
            - page_id: 1
              format: html
              cron: "0 3 * * *"  # Daily at 3 AM
    
  3. Custom Formats Implement Comsa\SuluPageExport\Exporter\ExporterInterface:

    class JsonExporter implements ExporterInterface
    {
        public function export(array $pageData): string
        {
            return json_encode($pageData, JSON_PRETTY_PRINT);
        }
    }
    

    Register in services.yaml:

    services:
        App\Exporter\JsonExporter:
            tags: ['sulu_page_export.exporter']
    

Integration Tips

  • Localization: Use Sulu’s locale system to export multilingual pages:
    php bin/console sulu:page-export:export --page-id=1 --locale=en_US
    
  • Media Handling: Override media paths in exports via config:
    sulu_page_export:
        media_base_url: "https://cdn.example.com"
    
  • Testing: Mock exports in PHPUnit:
    $this->container->get('sulu_page_export.exporter')->shouldReceive('export')->once();
    

Gotchas and Tips

Pitfalls

  1. Missing Dependencies Ensure sulu/core and sulu/admin are installed. The package won’t work without them.

  2. Permission Issues The exporter runs under the ROLE_SULU_ADMIN role by default. Custom roles may break exports:

    # Fix: Add to security.yaml
    access_control:
        - { path: ^/admin/sulu-page-export, roles: ROLE_SULU_ADMIN }
    
  3. Circular References Deeply nested page structures (e.g., recursive blocks) may cause infinite loops. Use max_depth in config:

    sulu_page_export:
        max_export_depth: 5
    

Debugging

  • Log Exports: Enable debug mode to log export paths:

    sulu_page_export:
         debug: true
    

    Check var/log/dev.log for paths like:

    [DEBUG] Export saved to: /var/www/var/exports/page-123.html
    
  • Validate Page IDs: Use sulu:page-export:validate to check if a page exists:

    php bin/console sulu:page-export:validate --page-id=999
    

Extension Points

  1. Pre/Post Export Hooks Subscribe to events:

    // src/EventListener/CustomExportListener.php
    use Comsa\SuluPageExport\Event\PreExportEvent;
    
    class CustomExportListener
    {
        public function onPreExport(PreExportEvent $event)
        {
            $event->getPage()->setMetadata(['custom_key' => 'value']);
        }
    }
    

    Register:

    tags:
        - { name: kernel.event_listener, event: sulu_page_export.pre_export, method: onPreExport }
    
  2. Custom Storage Override the default storage adapter:

    // src/Exporter/Storage/S3Storage.php
    use Comsa\SuluPageExport\Exporter\Storage\StorageInterface;
    
    class S3Storage implements StorageInterface
    {
        public function save(string $content, string $path): void
        {
            // Implement S3 logic
        }
    }
    

    Bind in services.yaml:

    Comsa\SuluPageExport\Exporter\Storage\StorageInterface: '@App\Exporter\Storage\S3Storage'
    
  3. Batch Exports Use the sulu:page-export:batch command for multiple pages:

    php bin/console sulu:page-export:batch --page-ids="1,2,3" --format=html
    

    Warning: Large batches may hit memory limits. Use --chunk-size=10 to process incrementally.

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