|
Project Information
Links
|
The mgframework project is the base for the Mangrove PHP framework. Mangrove aims to be a highly robust product offering new and uniform approaches to existing problems in web application development. In order to use the Mangrove PHP framework at least PHP 5.3 with the mbstring and intl extensions is required. Furthermore, it is highly recommended to utilize a caching mechanism like XCache or APC. Mangrove has been tested and proven to work on both Linux and Windows setups running Apache httpd 2.0+, Apache Tomcat 6, nginx and lighttpd with no additional php.ini settings. Mangrove is currently divided into three parts: Mangrove Core, Grove and Groove. Mangrove CoreMangrove Core contains the Mangrove Runtime, the dependency injection container and provides as the basis for the build of a Mangrove application. Mangrove Core can be used without Grove or Groove as the basis for any PHP application. GroveGrove is Mangrove's web application container. Grove enforces a DM-V-VM style approach to the development of the web application. This means that, unlike other frameworks, Grove doesn't use controllers. Grove requires the Mangrove Core in order to function. GrooveGroove is Mangrove's template engine, which adapts a rule based approach in order to map instances of classes towards small pieces of a template file (called templets). Groove also requires the Mangrove Core in order to function. Want to know more on these subjects? Be sure to check out the Wiki! For a quick start svn co https://mgframework.googlecode.com/svn/trunk/example will give you a ready to go example project. Point a virtual host to the www directory in the project and you're good to go. What does it look like?The following example shows a simple counter application, which stores a count in the user's session. Hitting the + or - link will result into the counter increasing or decreasing. Of course this isn't the most usable example, but it should capture the gist. /**
* The name by which the CounterApplication is referenced
*/
namespace counter;
/**
* A Profile can act like a simple gateway. Allowing or blocking access to applications,
* modules and/or specific actions.
*/
class CounterProfile extends \mg\Profile {
}
/**
* The CountActions interface describes the actions which can be invoked
* on the application in a request.
*/
interface CountActions implements \mg\Actions {
public function increase();
public function decrease();
}
/**
* The CounterApplication is the view model. It implements the public
* actions and maintains (in this case) state. Currently no data model is involved.
*/
class CounterApplication extends \mg\Application implements CountActions {
public $counter = null;
public function inject() {
$this->counter = new \mg\SessionInjection(0);
}
public function increase() {
$this->counter++;
}
public function decrease() {
$this->counter--;
}
}
And the template file to go with the code :
namespace counter;
$route = \mg\RouteHelper;
/**
* A simple rule will bring the CounterApplication to life, exposing its actions
* to a user of the application.
*/
CounterApplication {
<html>
<head></head>
<body>
Currently at $this->counter <br />
<a href="$route->to('/counter/-/decrease')|escape">-</a>
<a href="$route->to('/counter/-/increase')|escape">+</a>
</body>
</html>
}
|