To install the TiP framework, simply unpack the tarball inside your server. A common convention is to rename the tip directory to tip:
cd /path/to/server
tar xjf /path/to/tarball/tip-0.2.1.tar.bz2
mv tip-0.2.1 tip
Once installed, you are yet able to use the TiP framework. To do this, you must create a proper index.php file.
The simpliest site is a blank page. To let the TiP generates this page, use the following index.php:
<?php
// Define the TiP environment
require_once './tip/TIP.php';
// Modules configuration
$cfg = array(
'main' => array(
'type' => array('module', 'application'),
'engine' => array(
'type' => array('template_engine', 'rcbtng')
),
'data_engine' => array(
'type' => array('data_engine', 'bucket')
)
)
);
// "main" module instantiation
TIP_Type::getInstance('main');
// Application execution
$GLOBALS[TIP_MAIN]->go();
?>
See the blank page demo.
Every TiP application must have at least one TIP_Application module, in the above case the module called main.
The result is a blank page with a preamble and the <html> root item:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="it-IT" lang="it-IT">
</html>
The hard part to understand is the configuration of the modules.
A property of a module is a protected variable of the module. For instance, the type property is the $type variable defined in TIP_Type. The id property is a special property binded to the key of the $cfg global array.
Now we'll try to do something more useful than a blank page: the famous Hello world program. Keeping the index.php from the previous section, you should create the style and style/main directories.
$ ls
index.php tip/
$ mkdir -p style/main
$ ls
index.php style/ tip/
Inside the style/main directory, create the following head.rcbt file using your preferred text editor.
<head>
<title>Hello world (or {getProperty(title)})</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="description" content="{getProperty(description)}" />
<meta name="author" content="eNTiDi" />
<meta name="keywords" content="{getProperty(keywords)}" />
<meta name="robots" content="{getProperty(robots)}" />
<meta name="generator" content="tip" />
</head>
Do the same with the body.rcbt file.
<body>
<p>Hello, world!</p>
<p>The referer is "{REFERER}" and today is {date()}.</p>
</body>
See the hello world demo.
Now try to access the page: in few steps you have a working (and XHTML 1.0 compliant) dynamic site.
Getting startedwas last modified by Nicola on Tue 26 May 2009 05:39:25 PM CEST