Question

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?

Was it helpful?

Solution

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. :)

OTHER TIPS

Combining wordpress with other frameworks will make it very easy for you to shot yourself in the foot. If all what your clients want is an editor then you can just use tinymce without dragging the whole of wordpress into it, but if they are after the workflow and flexibility then it will be pointless to try to make wordpress something that it isn't. you are more likely to both spend more time then you anticipate on development and even then produce something which will not fully satisfy your clients.

I've accomplished this with Laravel using wp-api.org, Guzzle, caching, and I extended CyberDuck's package a bit to fit my needs. All my own views and my own routing.

When approaching it in this way, I found it easier to think of the WP admin area as more of a structured content repository, and less of a page management CMS. I heavily used ACF and my own custom plugins.

Many other WP plugins wouldn't work too well, as many produce output. You'd have to either figure out a way to get that output and print it yourself or build your own functionality instead.

I never ended up launching this one, as the project needed a basic shopping cart and WooCommerce fit the bill, so stuck w/ a custom WP theme instead. But it was a great learning experience and did work quite well, especially once caching was running.

But you will then have two applications to maintain. In my case, at least, it really only made good sense if I was going to build multiple websites or apps that all fed from the WP content repository.

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

Yes, if the application or domain warrants it. I greatly enjoyed using my own routing and views, so much more control. And I didn't have to touch any WP theme code, which is a huge bonus.

Any advantage of using only wordpress for the site rather than using an external framework for it?

Absolutely, one less application to maintain and much less code to write. All routing is built-in to WP. But you're stuck with how WP routes things, unless you really dig in to its rewrite engine and hack it up, which could mess with other plugins you may be running.

Is there some way to connect the Laravel routing system with the WordPress rewrite system?

I didn't dig much into this, as if I needed to use a rewrite/route structure that's similar enough to WP, I would've just stuck with WP in the first place. The main motivator for my project was that my domain's route structure simply wouldn't cooperate with WP's.

It really wasn't difficult to set up a route (i.e. post/{slug}) to query WP API for the {slug} and get the post's content.

Have you looked at October CMS?

The only reason I didn't use it for my newest project was because of SEO. Yoast's plugin on WordPress just handles a lot of stuff I don't want to deal with regularly.

Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange
scroll top