I am moving my site from Wordpress to Laravel 4 as the site has moved away from being a blog and requires more enterprise and custom functionality.
The blogging capabilities of Wordpress are Awesome, and I would like to continue using Wordpress for this functionality, letting it do what it does best natively.
Justification
I have built wp-plugins to achieve basic levels of required customisations, however I feel as though the site has outgrown wordpress. I really need an MVC solution and a clear separation of concerns for my webapp, without the need to intermix OOP MVC code with wp/procedural code.
I don't mind having 2 logins - wordpress backend & laravel backend...
Obviously, I would like the blog part of the site to look the same as the main part of the site.
I hope to achieve this by keeping installation of Wordpress in a separate folder to the main application Laravel.
From here, I have two options, load up wordpress from within laravel and use the wordpress api or alternatively, expose a json-api or similar of the blog.
This will provide added benefit of allowing me to create an Android / IOS app and share content between main site & mobile devices.
Access WP via wordpress api
config/app.php - Example
...
define('WP_USE_THEMES', false);
require_once(Config::get('app.wp_path') . '/wp-load.php');
wp();
....
this will enable me to access the posts via wordpress api.
Access WP via json-api plugin
Using this plugin, I will be able to create a blog model and query the wordpress posts via curl & json requests.
controllers/BlogController.php - Example
class BlogController extends BaseController {
public $restful = true;
public function getIndex() {
$data['posts'] = Blog::getPosts(1);
$data['page'] = 1;
return View::make('blog.index')->with($data);
}
}
models/Blog.php - Example
public static function getPosts($page = 1)
{
// get data from specified url via curl
$url = "http://domain.com/api/get_posts/?page=" . $page;
$posts = self::curl($url);
return $posts;
}
The Question(s)
At present, I like the idea of exposing a json-api because of future extensibility etc. Furthermore, wordpress will only be loaded when required.
I also like the clean and consistent way in which my wp posts can be accessed and displayed within Laravel application.
Any comments / considerations in relation to the following?
- Application Performance
- Security
- Anything that I haven't considered?
- Better way of integrating wordpress & laravel?