How To Create Plugin in WordPress MVC

WordPress is not MVC based CMS, so everybody wants to create plug-in based on MVC architecture.
wp-mvc is wonderful plugin of wordpress, which enables developer to create wordpress plugin based on MVC architecture. In this tutorial I will tell you how to create MVC based plugin with wp-mvc on your wordpress.
WP MVC provides a command line functionality to create WP MVC-based plugins. The plugins contains models, views, config and controllers basic structures. The base utility is located at plugins/wp-mvc/wpmvc folder.


1- First you will open command line and go to your wp-mvc path.

1
C:\wamp\www\wordpress\wp-content\plugins\wp-mvc

2- Run below command to create plugin structure.

1
wpmvc generate plugin test

Now you will plugin structure based on MVC. After creating a plugin, you’ll want to generate code for the models, views, and controllers of each of its resources.

3- In this step we will create plugin mvc resource

1
Wpmvc  generate scaffold test venues

Where test is the name of your plugin and venues is the name of your resource. The generated code will be added in plugins/test/app/ folder, by default name column will display on listing page, if name column is exist in table.

Finally you will see a venues menu is created your admin dashboard and add/edit and delete functionality are working. Now open admin controller file here you will see there are only default column name constant is only exit nothing other thing is written in file, so you thing how will working add/edit, it will work because it will inherit all functionality from base class, to modify add action you need to override add() action in your admin controller.

you can also create selectively model controller and views for a specified resource.

Here are some examples that should be fairly self-explanatory:

1
2
3
./wpmvc generate model test schedule
./wpmvc generate views test list
./wpmvc generate controllers test schedule
The following two tabs change content below.
Hi, This is Parvez Alam from India. I am software developer with 4 years’ experience in web development. I have submitted articles on PHP, Mysql, Magento,CSS, HTML, jQuery, web designing and social API. You can subscribe to my blog via RSS/Twitter/Google plus and Facebook. parvez1487(at)gmail(dot)com

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>