Moufpress is a MVC framework for Wordpress. Actually, it is a bridge between Wordpress and the Splash MVC framework used by Mouf-PHP (a dependency injection based framework).
MoufPress offers the following features:
- controllers, declared through a nice graphical DI container
- use of annotations in your controllers (for instance:
@URL
to declare a new route,@Logged
to restrict access to logged users, etc...) - support for any kind of views supported in Splash MVC (this includes plain PHP files, Twig templates, etc...)
- a nice web-based UI to scafold your controllers and views
- integration of your views inside the Wordpress theme
- (very) easy Ajax support
- creating Wordpress widgets through dependency injection in Mouf
- integration of Mouf's authentication and authorization system into Wordpress
- integration of Mouf's web library (JS/CSS) system into Wordpress
Another interesting feature is that your code is 100% compatible with Splash MVC. This means that:
- You can write a controller in Splash MVC and deploy it later in Wordpress (or the opposite)
- Since there is also a Drupal module for Splash (Druplash), you can actually write a controller in Wordpress and deploy it in Drupal (or the other way around). Yes, you read it correctly, you can develop an application that will run on both Wordpress and Drupal (!) Haha! I see you're interested. Let's get started!
You will first need to install Wordpress and Mouf side by side.
-
Start by installing Wordpress as you would normally do.
-
Install the WP-Router plugin.
Note: even if the plugin page stats this plugin works up to version 3.4 of Wordpress, we have tested with Wordpress 3.8.1 and it works great. -
Install the Mouf PHP framework in the same directory as Wordpress This means you should have the composer.json file of Composer in the same directory as the wp-config.php of Wordpress.
-
Modify composer.json and add the moufpress module. Your composer.json should contain at least these lines:
{ "autoload" : { "psr-0" : { "MyApp" : "src/" } }, "require" : { "mouf/mouf" : "~2.0", "mouf/integration.wordpress.moufpress" : "~1.0", }, "minimum-stability" : "dev" }
Do not forget to customize your vendor name (the
MyApp
part of the autoloader section). -
Create the empty
src/
directory at the root of your project. -
Run the install process in Mouf: connect to Mouf UI and run the install process for all the packages (including Moufpress install process of course)
-
When you downloaded Moufpress, Composer automatically copied a Moufpress plugin in the
wp-content/plugins
directory of Wordpress. You need to install this plugin. Connect to your Wordpress admin, select the Plugins > Installed plugins menu, and click on the "Activate" button for the "Moufpress" plugin. Also, do not forget to activate the WP Router module first if you haven't already done it.
In the next section, we will learn how to create a controller and a view.
Or if you already know Splash, you can directly jump to another part of this documentation: