I Use This!
Activity Not Available
Analyzed 12 months ago. based on code collected 12 months ago.

Project Summary

About xMVCxMVC is a light-weight MVC framework for PHP 5.3+ that intimately connects XML, XSLT and PHP. The concept behind xMVC is storing data in XML models, leveraging filenames and folder hierarchy to segregate data, and applying XSL transformations on only the XML models specified by the PHP controller. In other words, the controller loads XML models, puts them in a stack, and applies an XSL transformation (view) on this stack of XML models.

ControllersxMVC controllers are defined as static PHP classes. Models and views are manipulated within the controllers.

ModelsModels are XML files. For non-XML data, such as data from a database, a model-driver converts this data to XML. A select few model-drivers have been written to handle the most common non-XML formats (SQL and filesystem model-drivers so far). In this way, the models are always consistently XML. They are subsequently pushed into a view's model-stack from within the controller.

Inline PHP is supported in the XML models; however, it is almost always possible to avoid its use. It is also advisable to keep XML models PHP-free in order to allow third-party applications to cleanly read and write to the XML file.

ViewsViews are written in XSLT, and are invoked from within the controller. XSLTs are used to parse the various stacked models and output final results, usually as XHTML.

Client-side and server-side XSLT rendering are supported transparently by the framework. Configuration options exist to force server- or client-side rendering. Most development time for xMVC has been in the context of server-side XSLT rendering due to its guaranteed support regardless of client browser. However, it is up to the developer to decide which path to take.

As with XML models, XSLT views also support inline PHP. Although inline PHP in a view can come in handy, it is recommended to use the strings model driver to pass around variables originating from the controller. You can also choose to enable registerPHPFunctions.

xMVC vs other PHP MVC frameworksThis framework was not designed for the beginner in mind. It was designed for PHP programmers who do not want bulky frameworks but still want to maintain the MVC pattern. If your project deals in any way with XML, xMVC makes it ridiculously easy.

Because models are strictly XML and views are strictly XSLT, this can intimidate the average PHP coder. The bundled named-template application structure is a good stepping stone to initiate XSLT novices to XSLT in general. It makes heavy use of xsl:call-template in order to bridge the gap between the traditional PHP include function and XSLT. In the majority of cases, this is sufficient for simple websites. Using the CC module included in the download is recommended for larger projects (example code coming).

Those comfortable with storing data in XML will find the convenience of pushing XML data straight through to their XSLT views a major time-saver, especially when it comes to maintenance and localization.

It is also very small and makes a point to remain slim. Third-party libraries have thus far been avoided as core PHP has been able to provide all necessary functionality.

The disadvantages are lack of community support since no concerted effort has been put into publicizing this project. There is also a lack of testing and debugging-related features. There is an ongoing effort to resolve these issues.

Getting startedDownload the featured zip Extract to a folder in your web environment NOTE: With xMVC's default URL rewriting setup, the URL to access this folder must be by host-name only (no subfolders), such as http://xmvctest.local/. If you prefer to use subfolders, you will have to make modifications to the URL rewriting rules in the included .htaccess file.

We will soon make available an alternate version of the application portion of xMVC that makes use of xsl:apply-templates instead.

ExamplesBelow is a Controller, a few Models and a View to help illustrate what to expect. Some files reference other external files, which aren't displayed in the examples below. They can be found in the download package.

Note that the models and view are setup in named-template fashion, making ample use of xsl:call-template. Be aware that this is only one way of organizing your models and views, and you should not feel limited to this method. However, it has proven to work very well amongst groups of developers with varying experience levels due to its familiar similarity to PHP's include.

Controller (app/controllers/website.php)namespace xMVC\App;

use xMVC\Sys\XMLModelDriver;

class Website
protected $commonContent;

public function __construct()
$this->commonContent = new XMLModelDriver( "content/en/common" );
}Controller (app/controllers/home.php)namespace xMVC\App;

use xMVC\Sys\XMLModelDriver;
use xMVC\Sys\View;

class Home extends Website
public function __construct()

public function Index()
$pageContent = new XMLModelDriver( "content/en/home" );

$page = new View( "home" );
$page->PushModel( $this->commonContent );
$page->PushModel( $pageContent );
}Common Content (app/models/content/en/common.xml)NOTE: The str namespace is a utility namespace that allows any element to be created in whichever hierarchy needed. This is useful to quickly put together content in a hierarchical manner without worrying about discrete validation.

Example Website®
┬ę 2009 Example Website Corporation. All rights reserved.


Contact Us

Page Content (app/models/content/en/home.xml)

Home | Example Website

Hello World

Here is a list of search engines:




View (app/views/home.xsl)NOTE: The view is incomplete as it is missing required external xsl files. This is only an example.


controller domdocument framework model mvc php php5 view xml xpath xsl xslt

In a Nutshell, xmvc-php...

This Project has No vulnerabilities Reported Against it

Did You Know...

  • ...
    Black Duck offers a free trial so you can discover if there are open source vulnerabilities in your code
  • ...
    you can embed statistics from Open Hub on your site
  • ...
    55% of companies leverage OSS for production infrastructure
  • ...
    you can subscribe to e-mail newsletters to receive update from the Open Hub blog

30 Day Summary

Apr 9 2016 — May 9 2016

12 Month Summary

May 9 2015 — May 9 2016