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

Drupal Bundle Laravel Package

20steps/drupal-bundle

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation:

    composer require 20steps/drupal-bundle
    

    Ensure Drupal 7 is installed in web/ (default) or configure ekino_drupal.root in config/packages/ekino_drupal.yaml.

  2. Basic Configuration: Update config/packages/ekino_drupal.yaml with:

    ekino_drupal:
        root: "%kernel.project_dir%/web"
        strategy_id: ekino.drupal.delivery_strategy.symfony
    
  3. First Use Case: Use Drupal’s DrupalFlashBag in a Symfony controller to leverage Drupal’s messaging system:

    use Ekino\Bundle\DrupalBundle\Port\DrupalFlashBag;
    
    public function index(DrupalFlashBag $flashBag) {
        $flashBag->add('status', 'Hello from Symfony!');
        // Render Drupal's message queue via Symfony's templating.
    }
    

Implementation Patterns

Workflows

  1. Drupal Entity Access: Fetch Drupal entities (e.g., nodes) via configured repositories:

    $repository = $this->get('ekino_drupal.entity_repository.page');
    $node = $repository->find(1);
    
  2. Symfony-Drupal Session Sync: Use DrupalAttributeBag to store Symfony session data in Drupal’s session table:

    $session->getBag('ekino_drupal')->set('user_pref', 'dark_mode');
    
  3. Command-Line Drupal Integration: Access Drupal’s database or services in Symfony commands:

    use Drupal\Core\Database\Database;
    
    public function handle() {
        $db = Database::getConnection();
        $result = $db->query("SELECT * FROM node")->fetchAll();
    }
    

Integration Tips

  • Routing: Use Symfony’s router to generate Drupal paths (e.g., /node/1).
  • Twig: Extend Drupal’s theme system by passing Symfony variables to Twig templates.
  • Security: Leverage provider_keys to attach Symfony’s security token to Drupal’s authenticated requests.

Gotchas and Tips

Pitfalls

  1. Drupal 7 Dependency:

    • The bundle requires Drupal 7.x. Attempting to use it with Drupal 8/9 or Symfony 4+ may break.
    • Fix: Pin drupal/core-recommended to 7.x in composer.json if auto-updating.
  2. Session Conflicts:

    • Overriding session.storage_id without configuring DrupalSessionStorage will cause RuntimeException.
    • Fix: Ensure ekino.drupal.session.storage is registered in services.
  3. Entity Repository Caching:

    • Repositories are lazy-loaded. Accessing an undefined repository (e.g., ekino_drupal.entity_repository.unknown) throws InvalidArgumentException.
    • Fix: Pre-configure all needed repositories in ekino_drupal.entity_repositories.

Debugging

  • Logger: Use ekino.drupal.logger.watchdog to debug Drupal-Symfony interactions. Logs appear in Drupal’s watchdog table.
  • Database: Verify Drupal’s database connection is accessible via Symfony’s doctrine or raw PDO.

Extension Points

  1. Custom Delivery Strategies: Extend ekino.drupal.delivery_strategy.symfony to modify how Symfony routes to Drupal or vice versa.

    services:
        app.drupal_strategy:
            class: App\Strategy\CustomDrupalStrategy
            tags: ['ekino_drupal.delivery_strategy']
    
  2. Flash Message Handlers: Override DrupalFlashBag to customize message types or storage:

    class CustomFlashBag extends DrupalFlashBag {
        public function add($type, $message) {
            // Custom logic (e.g., log to Symfony's monolog).
            parent::add($type, $message);
        }
    }
    
  3. Entity Repository Extensions: Subclass Ekino\Bundle\DrupalBundle\Entity\EntityRepository to add custom methods:

    class CustomNodeRepository extends EntityRepository {
        public function findByTitle($title) { ... }
    }
    

    Register it in entity_repositories config.

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.
comsave/common
alecsammon/php-raml-parser
chrome-php/wrench
lendable/composer-license-checker
typhoon/reflection
mesilov/moneyphp-percentage
mike42/gfx-php
bookdown/themes
aura/view
aura/html
aura/cli
povils/phpmnd
nayjest/manipulator
omnipay/tests
psr-mock/http-message-implementation
psr-mock/http-factory-implementation
psr-mock/http-client-implementation
voku/email-check
voku/urlify
rtheunissen/guzzle-log-middleware