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

Ezplatform Kernel Laravel Package

ezsystems/ezplatform-kernel

eZ Platform Kernel provides the core Symfony-based runtime for eZ Platform/Ibexa CMS: content repository, persistence, REST and siteaccess handling, security, and extension points. Used as the foundation for building and running eZ Platform applications.

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation:

    composer require ezsystems/ezplatform-kernel
    

    Ensure your project extends EzSystems\EzPlatformKernel\EzPlatformKernel in config/bundle.php:

    new EzSystems\EzPlatformKernel\EzPlatformKernel($rootDir.'/config/bundle.php', $env),
    
  2. First Use Case:

    • Bootstrapping a Symfony Controller: Inject the Repository service to fetch content:
      use Ibexa\Contracts\Core\Repository\RepositoryInterface;
      
      class MyController extends AbstractController {
          public function index(RepositoryInterface $repository): Response
          {
              $searchService = $repository->getSearchService();
              $result = $searchService->findContent();
              // Render results...
          }
      }
      
  3. Key Files:

    • config/bundle.php: Kernel configuration.
    • config/services.yaml: Define custom services (e.g., ezpublish.siteaccess).
    • src/Kernel.php: Extend EzPlatformKernel for custom logic.

Implementation Patterns

Core Workflows

  1. Content Repository Integration:

    • Use RepositoryInterface to interact with content:
      $locationService = $repository->getLocationService();
      $contentService = $repository->getContentService();
      
    • Search: Leverage SearchService for queries:
      $query = new Query\Query();
      $query->query = new Query\Criterion\MatchAll();
      $result = $searchService->findContent($query);
      
  2. Siteaccess Management:

    • Configure siteaccesses in config/bundle.php:
      'siteaccess' => [
          'default' => 'site1',
          'list' => ['site1', 'admin'],
      ],
      
    • Switch dynamically in controllers:
      $repository->setCurrentSiteaccess('admin');
      
  3. Event Listeners:

    • Subscribe to Ibexa events (e.g., ContentPublish, LocationMove):
      # config/services.yaml
      services:
          App\EventSubscriber\MySubscriber:
              tags:
                  - { name: kernel.event_subscriber }
      
  4. Custom Content Types:

    • Define in YAML (e.g., config/ibexa/content_types/my_type.yaml):
      my_type:
          identifier: my_type
          fields:
              - { identifier: title, type: ezstring }
      

Integration Tips

  • Symfony Forms: Use ezpublish.form.type.content for content editing:
    $builder->add('content', ContentType::class, [
        'repository' => $repository,
    ]);
    
  • Twig Extensions: Register custom Twig functions:
    $twig->addFunction(new \Twig\TwigFunction('ez_current_siteaccess', [$repository, 'getCurrentSiteaccess']));
    
  • API Platform: Integrate with ezpublish.api for GraphQL/REST endpoints.

Gotchas and Tips

Pitfalls

  1. Siteaccess Context:

    • Forgetting to set setCurrentSiteaccess() can lead to silent failures (e.g., missing translations or content).
    • Fix: Always validate siteaccess in critical paths:
      if (!$repository->getCurrentSiteaccess()->getName() === 'admin') {
          throw new \RuntimeException('Invalid siteaccess');
      }
      
  2. Caching Quirks:

    • Ibexa caches aggressively. Clear caches after schema changes:
      php bin/console ezplatform:cache:clear
      
    • Debugging: Use ezplatform:cache:clear --env=dev to bypass production caching.
  3. Content Service Pitfalls:

    • ContentService::loadContent() returns null for unpublished content. Use ContentService::loadVersion() for drafts.
    • Tip: Chain ContentService::publishVersion() with ContentService::loadContent() to avoid race conditions.
  4. Dependency Injection:

    • Avoid manual instantiation of Repository or SearchService. Always inject via Symfony’s DI container.
    • Error: ServiceNotFoundException often means missing ezpublish.siteaccess config.

Debugging Tips

  • Log Levels: Enable Ibexa’s debug logs in config/packages/ez_platform.yaml:
    ez_platform:
        system:
            debug: true
    
  • Query Debugging: Use Query::debug() to inspect search queries:
    $query->debug(true);
    
  • Database Dumps: Export Ibexa’s schema with:
    php bin/console doctrine:schema:dump --em=ezpublish
    

Extension Points

  1. Custom Field Types:
    • Extend FieldType and register in config/ibexa/field_types.yaml:
      my_field_type:
          type: App\FieldType\MyFieldType
      
  2. Repository Events:
    • Override EzSystems\EzPlatformKernel\Event\KernelEvents for custom logic:
      $dispatcher->addListener(KernelEvents::PRE_BOOT, [$this, 'onKernelPreBoot']);
      
  3. MVC Layer:
    • Extend EzSystems\EzPlatformKernel\Controller\ContentController for custom routes:
      class CustomContentController extends ContentController {
          public function customAction(RepositoryInterface $repository) { ... }
      }
      
    • Register in config/routes.yaml:
      app_custom_content:
          path: /custom
          controller: App\Controller\CustomContentController::customAction
      
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