public
Last active

Integrate Symfony 2 with Wordpress

  • Download Gist
index.php
PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
<?php
require_once __DIR__.'/../symfony/app/bootstrap.php.cache';
require_once __DIR__.'/../symfony/app/AppKernel.php';
 
use Symfony\Component\HttpFoundation\Request;
 
$kernel = new AppKernel('dev', true);
$kernel->loadClassCache();
 
$response = $kernel->handle(Request::createFromGlobals());
 
// check to see if a route match in Symfony 2
if($response->getStatusCode() !== 404) {
// if do, send continue Symfony 2 app
$response->send();
} else {
// if there is no match, bootstrap and forward to Wordpress
 
// tells WordPress to load the WordPress theme and output it.
define('WP_USE_THEMES', true);
 
// loads the WordPress Environment and Template
require('./wp-blog-header.php');
}

This works great! The only thing lasting is an Twig interface for the wordpress codex functions

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.