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.
Installation:
wordpress/ and Symfony in symfony/ directories.ekino/wordpress-bundle to symfony/composer.json and run composer update.AppKernel.php and include its routing in routing.yml.Configure:
app/config.yml with WordPress directory path, table prefix, and security settings.wordpress/index.php to load Symfony’s kernel and container.First Use Case:
symfony() helper.ekino.wordpress.manager.post).Symfony-to-WordPress Data Flow:
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);
WordPress-to-Symfony Integration:
symfony():$service = symfony('my.symfony.service');
$data = $service->fetchData();
Authentication:
ekino-wordpress-symfony plugin and security.yml:firewalls:
secured_area:
entry_point: ekino.wordpress.security.entry_point
Event Dispatching:
EventDispatcher (requires plugin).load_twig_extension: true to use WordPress functions (e.g., get_option()) in Twig.ekino_wordpress route last in routing.yml to catch all WordPress URLs.{{ wp_get_header() }}
{{ wp_get_sidebar() }}
Debugging:
kernel.debug is true in config.yml for Symfony errors to display in WordPress..htaccess rules for URL rewrites; conflicts may break WordPress routes.Configuration Quirks:
table_prefix in config.yml matches WordPress’s wp_ prefix.enable_wordpress_listener is false, WordPress hooks won’t trigger Symfony events.Plugin Dependencies:
ekino-wordpress-symfony plugin is required for authentication and event dispatching. Install it in WordPress.symfony()->get('debug.stopwatch') to inspect request lifecycle.wp_cache_flush()) after Symfony DB changes.cache:clear) if roles don’t sync.Custom Entities/Managers:
config.yml:
ekino_wordpress:
services:
post:
class: AppBundle\Entity\CustomPost
$manager->create()).Repositories:
ekino_wordpress:
services:
comment_meta:
repository_class: AppBundle\Repository\CustomCommentMetaRepository
I18n:
ekino_wordpress:
i18n_cookie_name: pll_language # Match WordPress plugin cookie
Password-Protected Posts:
cookie_hash in config.yml if using custom COOKIEHASH in WordPress.wp_cache_get()).How can I help you explore Laravel packages today?