WordPress as Backend, Laravel Front End: How to connect Routes?

I am going design a site and I though about using wordpress for it as the clients want to be able to edit the content and they are not very up to date with the latest technologies, so I though that as wordpress backend editor is quite simple and straight forward, this could be a nice option for it.

Then, I though about just using it as a backend and mix it with some framework such as Laravel or CakePHP to do the rest of the work and design the views.

Do you think this would be a nice approach to it?

When thinking about only using wordpress themes for it, I found myself in trouble when I start thinking about URL routing, having to understand which template files are called for each URL, dealing with forms, detection of touch/mobile devices in the backend.

And on the other hand, I know how to deal with that in other PHP frameworks, so it seems easier for me to do it there.

Any advantage of using only wordpress for the site rather than using an external framework for it? Is there some way to connect the Laravel routing system with the WordPress rewrite system?

4 Answers
4

The thing about WordPress, while it doesn’t have a neat routing system in principle it does same operation. It takes the URL input and matches it to a set of query variables.

The not–neat thing about it is that it uses regular expressions for these not–quite–routes and a lot of them. The total number of rules fluctuates from about a hundred minimum to thousands for a complex site (dump $wp_rewrite->rules to see).

This system is entirely possible to replace (it likely won’t be particularly clean, bordering on crazy hack from WP perspective though).

The main challenge is that you would have to spent enormous effort for feature parity, that is your router not breaking 90% of things that “just work” in WP.

If you aren’t concerned about feature parity you could very well just do a small subset of them and ignore the rest.

PS or you could just make a WP site like it’s meant to be done. That works for plenty of people. 🙂

Leave a Comment