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
1- First you will open command line and go to your wp-mvc path.
2- Run below command to create plugin structure.
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
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