WordPress Plug-in Development In MVC Architecture

You could definitely use an MVC philosophy in the development of a plugin, but you would be really silly to try to incorporate CI or Cake in addition to WP.

For instance, you could build out a plugin using the following pseudo structure (FYI, there are a ton of ways to build this, depending on your interpretation of MVC. This is just the quick example that pops into mind):

class Plugin(){
    function __construct(){ // controller?
        run conditionals/determine query
        process model
        process view
    }
    function model(){ 
        get query from database 
        return variables
    }
    function view(){
        echo html
    }
}

This might be a horrible example of a plugin structure, or even of MVC, but it is simply to illustrate that MVC architecture !== MVC frameworks and that MVC can be used in plugin design. Widget classes and other functionality throughout WP are similar, although without any explicit separation of concerns.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s