ekino / ekino-wordpress-symfony

43 stars 13 forks source link

ekino-wordpress-symfony

This is the Ekino Wordpress plugin to interact with Symfony.

Installation

1) Put the following lines at the beginning of your wp-config.php file, according to your project configuration:

define('WP_SYMFONY_PATH', __DIR__.'/symfony/');
define('WP_SYMFONY_ENVIRONMENT', 'dev');
define('WP_SYMFONY_DEBUG', true);

2) Enable the "Ekino Wordpress Symfony" plugin in WordPress Extensions list.

Usage

Retrieve a Symfony service

You can retrieve all Symfony services registered in the dependency injection container with the following method:

$service = \symfony_service('my.symfony.service.identifier');

Dispatch Wordpress hooks in Symfony using EventDispatcher

This plugin allows Wordpress to dispatch some hooks on the Symfony EventDispatcher component.

An example with the three following hooks has been added: