Tag dwoo

First use
To install pampoo you need the following requirements:
php 5.2 or later 

Pampoo is designed to divide application classes and well manage code update. It requires a sitemap to decide how to route web request and some classes called controllers to handle those requests

This is  a sample  sitemap file:
<?xml version="1.0" encoding="utf-8"?>
<config>
<actions> 
	<action id="home">
		<controller value="Controllers_Home"/>
		<view name="SUCCESS" type="trasformation">
			<trasform>Views/Home.xsl</trasform>
		</view>
	</action>
</actions>
</config>

This is the example controller associated with this sitemap :
<?php
class Controllers_Home extends Pampoo_BLL_Serializable {
     
   public function InitController() {		
	$this->model->Message = "Hello world!";
	return "SUCCESS";
	}
}
?>
Now you need a view to render (output to browser) the message; this view is defined in <transform> tag in the sitemap. The example rendering view is Views/Home.xsl. This is the content:

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

	<xsl:template match="/">
	<html>
	<head>
		<title>My first web page with Pampoo</title>
	</head>
	<body>
		<h2><xsl:value-of select="//Message"/></h2>
	</body>
	</html>	
	</xsl:template>

</xsl:stylesheet>

Now that you have created the controller and the view you need an application entry point (e.g.: index.php) where you can initialize the framework. Assuming the directory containing the application is /var/www/html (and Pampoo framework is located under /var/www/html/lib/Pampoo) this is a valid example application entry point:
<?php
session_start();
ob_start();
date_default_timezone_set('Europe/Rome');
  
require_once "/var/www/html/lib/Pampoo/Pampoo.php";

require_once "Controllers/Home.php";

Pampoo::init("/var/www/html/", "/var/www/html/sitemap.xml");
Pampoo::Run(); 
?>
Assuming your webserver address is http://localhost point your browser to http://localhost/index.php?action=home you should view the magic words "Hello world"!

Download the application sample at Sourceforge
Dwoo as template engine
What is Dwoo?
Dwoo is a PHP5 template engine which is (almost) fully compatible with Smarty templates and plugins, but is written from scratch for PHP5, and adds many features. --Taken from dwoo.org--

You can use php templates in your Pampoo powered application. This is an example action containing a view that will use dwoo template engine:
<action id="home">
	<controller value="Controllers_Home"/>
	<view name="SUCCESS" type="dwoo">
		<trasform>Views/Home.tpl</trasform>
	</view>
</action>

Dwoo is very powerful and has many features including:
  • Template Inheritance, a fresh look at complex template structures, now built without includes
  • Sub-template declaration within templates to allow recursive templates.
  • Smarty syntax compatibility with several additions and shortcuts to speed up template writing
  • Flexible plugin creation, plugins can be wrapped in classes or simple functions, they can be precompiled to optimize the load time of the template, etc.
  • Scope aware engine, allowing for shorter templates
  • Unicode / UTF-8 support for string manipulation functions.
  • Generally faster than Smarty with variable speed improvements depending on the features used.
  • E_STRICT compliant code that does not throw PHP warnings.

From Wikipedia: Model-View-Controller (MVC) is a software architecture, currently considered as an architectural pattern used in software engineering. The pattern isolates "domain logic" (the application logic for the user) from input and presentation (GUI), permitting independent development, testing and maintenance of each.

Chiudi