Kniblet Tutorial Part 2
From n² wiki
Development Environment
We will be developing the Kniblet application on an Apache Web server running locally (communicating with the Talis Platform over HTTP), coding in PHP.
Any programming-friendly text editor or IDE is suitable.
Software Requirements
Linux
synaptics/apt-get install - package names?
MS Win
- Apache 2
OS X
- Apache 2
- Mac OS X 10.5 (Leopard) Comes With Apache 2 and PHP 5 - is installed by default? (presumably not)
- Complete Apache 2.0.52 - comes as pkg, haven't tested
Local Host Config
minimum necessary? can we provide setup scripts..?
/etc/hosts add kniblet.local to the line beginning 127.0.0.1, e.g.
127.0.0.1 localhost kniblet.local
add a file /etc/apache2/site-available
(change path to fit local) [[
NameVirtualHost kniblet.local <VirtualHost kniblet.local> DocumentRoot /home/danny/workspace/N2/tutorials/kniblet/ <Directory /home/danny/workspace/N2/tutorials/kniblet/> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all </Directory> </VirtualHost>
]]
ln -s /etc/apache2/site-available /etc/apache2/site-enabled
Directory Structure
// pull all this from svn?
export konstrukt, moriarty
download arc
- src
- lib/arc
- lib/konstruct
- lib/moriarty
- etc.
add to path
copy konstrukt's blank_project :
root.php to /src
index.php to /www
create src/templates
.htaccess rewrite rules
- existing dirs/files handled by Apache
- everything else handled by index.php
index.php is housekeeper
root.php does the work (controller)
URI Design
/articles - browsable list
/articles/pagename - individual articles
Controllers
from setting up the env
index.php is housekeeper
root.php does the work (controller)
src/articlecontroller.php
src/templates/articlelist.tpl.php
src/article.tpl.php
The root template can be very simple to start with, just enough to show the embedded content:
<html> <head> <title>Kniblet</title> </head> <body> <p>This is global navigation</p> <p> <?php echo $content; ?> </p> </body> </html>

