Skip to content

Instantly share code, notes, and snippets.

@AtsushiSuzuki
Created December 4, 2015 08:01
Show Gist options
  • Save AtsushiSuzuki/e4435736a410f1a09820 to your computer and use it in GitHub Desktop.
Save AtsushiSuzuki/e4435736a410f1a09820 to your computer and use it in GitHub Desktop.
PHPフレームワークとWordpressを共存させる
<?php
require_once __DIR__ . '/vendor/autoload.php';
$app = new \Silex\Application();
$app->get('/hello', function () {
return 'Hello, world!';
});
$app->error(function ($ex) use ($app) {
if ($ex instanceof \Symfony\Component\HttpKernel\Exception\HttpException &&
$ex->getStatusCode() === 404) {
return $app->stream(function () {
/**
* Front to the WordPress application. This file doesn't do anything, but loads
* wp-blog-header.php which does and tells WordPress to load the theme.
*
* @package WordPress
*/
/**
* Tells WordPress to load the WordPress theme and output it.
*
* @var bool
*/
define('WP_USE_THEMES', true);
/** Loads the WordPress Environment and Template */
require( dirname( __FILE__ ) . '/web/wp-blog-header.php' );
});
}
});
$app->run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment