1

Just started learning wordpress... will start developping soon... is it recommended to start with an MVC framework for wordpress? tbh it's hard to follow/understand plugins as each developer use his own style (most of time it's like spaghetti coding)... will a MVC framework make a plugin more maintenable.. are there limits/constraints of using the MVC approach in wp?

2

is it recommended to start with an MVC framework for wordpress?

Not really. WP has no native inclination or affinity for MVC.

tbh it's hard to follow/understand plugins as each developer use his own style (most of time it's like spaghetti coding)...

Welcome to WordPress. :) Have no doubt though — people can mess up MVC just as thoroughly.

will a MVC framework make a plugin more maintenable.. are there limits/constraints of using the MVC approach in wp?

If you have knowledge and skills for specific approach then it would be easier and more convenient to maintain for you. And the other way around. There are very few universal conventions in WP development for code organization.

  • It's more difficult to mess up with MVC lol ... i work with prestashop and it uses MVC... although some modules are "messed up", it's still very easy to debug, read and follow the code. Lol I am glad to read that I am not the only one finding WP a bit disorganised and lacks convention for code organisation... hope they improve and give a more "strict" development guidelines in future versions. – yeahman Apr 12 '14 at 6:03
0

I can feel the pain because I was going through the same problem. If you are working in a team & there is no standard procedure to follow, things get messy pretty fast. Everyone starts writing code in their own way & at the end of the day it looks like a spaghetti code. Most of the time I work with experienced WordPress developers, therefore they are already aware of wp functions that are used frequently. It is just that everyone has his/her own style. Hence to solve the problem of spaghetti code, a defined structure & coding standard is required.

In my case, to solve the problem of structure, I have created a boilerplate that defines the structure to follow. The boilerplate aims to separate concerns between Model, View & Controller.

Dveloper gets a chance to write individual Model, View & Controller classes. Also, the concern of whether to load a controller/model or not is delegated to Router, so that your controller & model can focus only on what they are supposed to do. I believe this would help in keeping the footprint small & keep things fast. Router automatically calls required models, controllers & views.

Since this is meant to be a boilerplate & not full fledge mvc framework, it does not have things like ORM, Helpers or any other extra goodies. It only focuses on one thing & that is to allow developer write MVC code.

Now that problem of structure is solved, we can look at coding standard related problem. The problem of coding standard is easy to solve. Developer has to follow WordPress Coding Standards & should use tool like phpcs,phpcbf,phpmd to deal with coding standard problems.

Here is a link to the boilerplate: https://github.com/sumitpore/mvc-plugin-boilerplate-for-wordpress/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.