Download the PHP package ekino/wordpress-bundle without Composer
On this page you can find all versions of the php package ekino/wordpress-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package wordpress-bundle
EkinoWordpressBundle
This bundle is used to bring some Symfony services into Wordpress and manipulates Wordpress using Symfony.
Here are some features:
- Use custom Symfony services into Wordpress,
- Use Symfony to manipulate Wordpress database,
- Create custom Symfony routes out of Wordpress,
- When authenticated on Wordpress, authenticated on Symfony too with correct user roles. (requires ekino-wordpress-symfony Wordpress plugin)
- Catch some Wordpress hooks to be dispatched by Symfony EventDispatcher (requires ekino-wordpress-symfony Wordpress plugin)
Installation
Idea of this installation tutorial is to have WordPress rendered by web root with the following architecture:
1) Install Symfony and WordPress
Install your Wordpress project in a wordpress
directory by unzipping the latest WordPress sources from https://www.wordpress.org.
Install Symfony using composer (for instance, or new Symfony Installer tool) in a symfony
directory:
2) Install ekino/wordpress-bundle into Symfony's project
Edit symfony/composer.json
file to add this bundle package:
Run php composer.phar update ekino/wordpress-bundle
Then, add the bundle into symfony/app/AppKernel.php
:
Add the WordpressBundle routing file in your symfony/app/config/routing.yml
, after your custom routes to catch all Wordpress routes:
Edit your configuration and specify the following options in your app/config.yml
:
Also optionally, if you want to use UserHook
to authenticate on Symfony, you should add this configuration to your symfony/app/security.yml
:
3) Update your WordPress index.php file to load Symfony libraries
4) In the case you expose Symfony only
To avoid problem with some Wordpress plugin, you need to wrap web/app.php
code inside a function like this:
5) Edit .htaccess file on your WordPress root project directory
Put the following rules:
You're ready to go.
Use in Symfony
You can call Wordpress table managers in Symfony by calling the following services:
Service identifier | Type |
---|---|
ekino.wordpress.manager.comment | Wordpress comment manager |
ekino.wordpress.manager.comment_meta | Wordpress comment metas manager |
ekino.wordpress.manager.link | Wordpress link manager |
ekino.wordpress.manager.option | Wordpress option manager |
ekino.wordpress.manager.post | Wordpress post manager |
ekino.wordpress.manager.post_meta | Wordpress post metas manager |
ekino.wordpress.manager.term | Wordpress term manager |
ekino.wordpress.manager.term_relationships | Wordpress term relationships manager |
ekino.wordpress.manager.term_taxonomy | Wordpress taxonomy manager |
ekino.wordpress.manager.user | Wordpress user manager |
ekino.wordpress.manager.user_meta | Wordpress user metas manager |
So in custom Symfony controllers, you can create / update / delete data in Wordpress database, like that:
Use in WordPress
Call a service from Symfony container
Simply use the symfony()
method and call your custom service like that:
Override
Entities
For every Wordpress entities, you can override the default classes. To do so, just add the following configuration in your config.yml
(for Post
entities):
In order to avoid further troubles when creating a new instance (for example), remember to always use the manager to create a new entity ($container->get('ekino.wordpress.manager.post')->create()
).
Managers
You can use your own managers too. To customize it, register yours as services — should be marked as privates — as follow :
Your manager will now be reachable using the usual command, IE from a controller : $this->get('ekino.wordpress.manager.comment')
Repositories
Implementing your custom repository classes is as simple as follow :
Extra
Enable cross application I18n support
If you already have a wordpress plugin to handle I18n, EkinoWordpressBundle allow to persist language toggle between Symfony and wordpress. To do so, just grab the cookie name from the wordpress plugin used and provide its name in the configuration as follow :
Also, you can implement your own language switcher in Symfony that work cross application. For instance :
Handling password protected posts
If you use password protected posts and you have defined your own COOKIEHASH
constant, you can provide it using the cookie_hash
parameter in your config.yml
file.
You will then be able to use the wp_post_password_required
twig function that behave exactly like post_password_required
Wordpress function.
Display Wordpress theme into a Symfony Twig-rendered route
You can display the WordPress header (with administration menu bar if available), sidebar and footer into your Symfony's Twig templates by using the following Twig functions available in this bundle:
All versions of wordpress-bundle with dependencies
symfony/framework-bundle Version ^2.6|^3.0|^4.0
symfony/security-bundle Version ^2.6|^3.0|^4.0
symfony/monolog-bundle Version ^2.2|^3.0|^4.0
doctrine/doctrine-bundle Version ^1.0
doctrine/orm Version ^2.2
hautelook/phpass Version 0.3