When my sites used to run on CodeIgniter, I would integrate Movable Type by not allowing Movable Type to display my content. Sure, I used Movable Type to manage the content, but I would build a presentation layer in CodeIgniter.
I retired both CodeIgniter and Movable Type, which left me with the puzzling question of how to make Laravel and WordPress co-exist. I learned my lesson — let the content management system handle the presentation layer and preserve walls between systems. (You’re reading the wrong blog entry if you’re looking for a way to integrate WordPress with Laravel.)
I ended up with a few solutions, due to some design constraints held over from the CI/MT days.
Keep everything separate
This blog resides under the sub-domain of blog.vigilantmedia.com, and it runs on WordPress. The main portfolio site is run on Laravel, and the only way either is connected is through navigation.
I’ve even differentiated the look and feel of the sites to enforce that separation.
vigilantmedia.com/ www/ app/ bootstrap/ public/ vendor/ wp/ wp-admin/ wp-content/ wp-includes/
Run Laravel as the main site with WordPress as a sub-directory
The document root of a server running Laravel points to the public folder, which means WordPress could run in its own directory.
Gregbueno.com is structured that way because the individual blogs are sub-sites under the gregbueno.com domain.
gregbueno.com/ www/ app/ bootstrap/ public/ wp/ wp-admin/ wp-content/ wp-includes/ vendor/
Run WordPress as the main site with an alternate Laravel index
Now things get interesting.
Both index.php files in WordPress and Laravel want to control the document root. In this solution, something has to give.
In the case of Duran Duran Networks, the blog is the main site, and the Laravel pages are the off-shoots. So, WordPress gets to rule the document root. The Laravel index file gets renamed to lv.php.
Since the site doesn’t have much content, it’s easy to manipulate the RewriteEngine of Apache to redirect specific paths to Laravel, while letting WordPress figure everything else out.
Note how the WordPress installation itself resides as a sub-directory of the Laravel public folder.
duran-duran.net/ www/ app/ bootstrap/ public/ .htaccess index.php lv.php wp/ wp-admin/ wp-content/ wp-includes/ vendor/
The following RewriteRule is added to the RewriteEngine section of the WordPress .htaccess file. It’s a regular expression looking for specific paths to route to lv.php.
RewriteRule ^(tour|album|login|logout|admin|signin)(|\/) /lv.php [L]
At some point, this solution is going to get unwieldy as the Laravel content grows, but for now, it works.