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

Wordpress Bundle Laravel Package

behappy/wordpress-bundle

Symfony bundle to integrate WordPress with Symfony: expose Symfony services in WordPress, manipulate WordPress DB via Symfony, create Symfony routes from WordPress, and optionally sync auth/roles and dispatch WP hooks through Symfony EventDispatcher.

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup Steps

  1. Installation:

    • Place WordPress in wordpress/ and Symfony in symfony/ directories.
    • Add ekino/wordpress-bundle to symfony/composer.json and run composer update.
    • Register the bundle in AppKernel.php and include its routing in routing.yml.
  2. Configure:

    • Update app/config.yml with WordPress directory path, table prefix, and security settings.
    • Modify wordpress/index.php to load Symfony’s kernel and container.
  3. First Use Case:

    • Inject Symfony services into WordPress via symfony() helper.
    • Use WordPress managers in Symfony controllers (e.g., ekino.wordpress.manager.post).

Implementation Patterns

Workflows

  1. Symfony-to-WordPress Data Flow:

    • Use managers (e.g., ekino.wordpress.manager.user) to CRUD WordPress data from Symfony controllers.
    $postManager = $this->get('ekino.wordpress.manager.post');
    $post = $postManager->find(1);
    $post->setTitle('Updated via Symfony');
    $postManager->save($post);
    
  2. WordPress-to-Symfony Integration:

    • Access Symfony services in WordPress templates via symfony():
    $service = symfony('my.symfony.service');
    $data = $service->fetchData();
    
  3. Authentication:

    • Leverage WordPress login for Symfony access via ekino-wordpress-symfony plugin and security.yml:
    firewalls:
        secured_area:
            entry_point: ekino.wordpress.security.entry_point
    
  4. Event Dispatching:

    • Hook WordPress actions/filters into Symfony’s EventDispatcher (requires plugin).

Integration Tips

  • Twig Extensions: Enable load_twig_extension: true to use WordPress functions (e.g., get_option()) in Twig.
  • Routing: Place ekino_wordpress route last in routing.yml to catch all WordPress URLs.
  • Theming: Embed WordPress themes in Symfony templates using Twig functions:
    {{ wp_get_header() }}
    {{ wp_get_sidebar() }}
    

Gotchas and Tips

Pitfalls

  1. Debugging:

    • Ensure kernel.debug is true in config.yml for Symfony errors to display in WordPress.
    • Check .htaccess rules for URL rewrites; conflicts may break WordPress routes.
  2. Configuration Quirks:

    • Table Prefix: Verify table_prefix in config.yml matches WordPress’s wp_ prefix.
    • Security: If enable_wordpress_listener is false, WordPress hooks won’t trigger Symfony events.
  3. Plugin Dependencies:

    • ekino-wordpress-symfony plugin is required for authentication and event dispatching. Install it in WordPress.

Debugging Tips

  • Service Access: Use symfony()->get('debug.stopwatch') to inspect request lifecycle.
  • Database Conflicts: Reset WordPress cache (wp_cache_flush()) after Symfony DB changes.
  • Authentication Issues: Clear Symfony’s security context cache (cache:clear) if roles don’t sync.

Extension Points

  1. Custom Entities/Managers:

    • Override default managers in config.yml:
      ekino_wordpress:
          services:
              post:
                  class: AppBundle\Entity\CustomPost
      
    • Use managers to instantiate entities (e.g., $manager->create()).
  2. Repositories:

    • Replace default repositories:
      ekino_wordpress:
          services:
              comment_meta:
                  repository_class: AppBundle\Repository\CustomCommentMetaRepository
      
  3. I18n:

    • Sync language cookies between apps:
      ekino_wordpress:
          i18n_cookie_name: pll_language  # Match WordPress plugin cookie
      
    • Implement cross-app language toggling via Symfony controllers.
  4. Password-Protected Posts:

    • Set cookie_hash in config.yml if using custom COOKIEHASH in WordPress.

Performance

  • Lazy Loading: Managers fetch data on-demand; avoid eager-loading large datasets.
  • Caching: Cache WordPress queries in Symfony (e.g., wp_cache_get()).
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.
bugban/symfony
beyonder-capi/workflow-extensions-bundle
beyonder-capi/job-queue-bundle
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin