Activity Not Available
0
I Use This!

Project Summary

Analyzed 4 months ago. based on code collected 4 months ago.

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()
{
parent::__construct();
}

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

$page = new View( "home" );
$page->PushModel( $this->commonContent );
$page->PushModel( $pageContent );
$page->RenderAsHTML();
}
}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.



Home
/


Contact Us
/contact-us/



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

Home | Example Website

Hello World

Here is a list of search engines:



Google
http://www.google.com/


Yahoo
http://www.yahoo.com/


MSN
http://www.msn.com/


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

Share

In a Nutshell, xmvc-php...

Activity

30 Day Summary

Apr 9 2016 — May 9 2016

12 Month Summary

May 9 2015 — May 9 2016

Community