Skip to content

Instantly share code, notes, and snippets.

@seansch
Created February 15, 2016 17:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seansch/cd227732d1b4415bd0dc to your computer and use it in GitHub Desktop.
Save seansch/cd227732d1b4415bd0dc to your computer and use it in GitHub Desktop.
Simple Laravel / Wordpress Integration
// public/index.php
// Wordpress / Laravel Integration
// Wordpress lives in public/wp/
if ( file_exists(__DIR__.'/wp/index.php') ) {
// Retrieve the current URL
$segments = explode('/', trim($_SERVER['REQUEST_URI'], '/'));
// Get first URL segment, strip any GET params
$segment = strtok($segments[0], '?');
// Reserved app URLS, these will all be routed to Laravel,
// All others will be passed to Wordpress.
$urls = ['reseverd-url1','reseverd-url2','reseverd-url3','auth', 'password', 'etc'];
if ( ! in_array($segment, $urls) ) {
// Load Wordpress
require_once __DIR__.'/wp/index.php';
exit;
}
}
// End Wordpress integration
/**
* Laravel - A PHP Framework For Web Artisans
*
* @package Laravel
* @author Taylor Otwell <taylorotwell@gmail.com>
*/
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment