On the command line, run the following commands:
$ cd /path/to/your/site
$ ./elefant build-app hello
This will create the directory structure for your new app. You can also simply create the folders manually if you prefer, or aren't comfortable on the command line. The folder structure is as follows:
apps/
hello/
handlers/
index.php
views/
index.html
Open the file apps/hello/handlers/index.php and add this code:
<?php
// get the name parameter from the URL
list ($name) = count ($this->params) ? $this->params : 'World';
// send the request on to the view template
echo $tpl->render ('hello/index', array ('name' => $name));
?>
Where did
$thisand$tplcome from? Think of them like$_GETand$_POST. They're created for you by the front controller (the mainindex.php) so your script has access to them without the need to create them yourself.$thisis a Controller object, and$tplis a Template object.
Open the file apps/hello/views/index.html and add this code:
<p>Hello {{ name }}</p>
You can now go to the URL /hello/John on your site and you should see the output <p>Hello John</p>.