Wallogit.com
2017 © Pedro Peláez
Use WordPress as the CMS backend for your Symfony 2 application., (*1)
Download Symfony WordPress Edition which comes set up to use this bundle, OowpBundle and a few useful WordPress plugins., (*2)
composer.json
"require": {
"outlandish/routemaster-bundle": "dev-master",
},
Until a way is found to allow Composer to install and manage WordPress, this script can be used to ensure WordPress is present:, (*3)
"scripts": {
"post-install-cmd": [
"Outlandish\\RoutemasterBundle\\Composer\\WordPressInstaller::install"
],
"post-update-cmd": [
"Outlandish\\RoutemasterBundle\\Composer\\WordPressInstaller::install"
]
},
composer update
AppKernel.php
public function registerBundles()
{
$bundles = array(
//...
new Outlandish\RoutemasterBundle\OutlandishRoutemasterBundle(),
);
return $bundles;
}
<?php use Symfony\Component\Debug\ExceptionHandler; use Symfony\Component\HttpFoundation\Request; //load WordPress require 'wp-load.php'; require_once __DIR__ . '/../app/autoload.php'; require_once __DIR__ . '/../app/AppKernel.php'; //...
Use Countroller and Routing
components as you would in a normal Symfony application. The front controller web/index.php loads WordPress before
booting Symfony which means standard WordPress functions and classes such as WP_Query
are available in your Symfony controllers., (*4)
It is recommended (for performance and simplicity) to use WordPress's $wpdb global if you require direct database
access but you could also use Doctrine or another ORM., (*5)
Caching is best handled by WordPress. Since WP is loaded first, a cache hit means that Symfony is not loaded at all., (*6)
Most WordPress plugins will continue to work, especially those that mainly affect the admin side. If in doubt, try it and see. It is recommended to use Composer and WPackagist for plugin management., (*7)
Normal WordPress themes will not work here. But you knew that, right?, (*8)