» Download, installation and first steps
Download, installation and first steps
This is a step-by-step tutorial, which shows you how to set up and use the Adventure PHP Framework
First, you need a PHP capable server. As local test server under windows you might have a look at
contains an installation of all important server components like Apache, PHP, MySQL, etc. Depending
on your setup, you need to adjust the paths used in this tutorial. On LINUX/UNIX boxes you might
install the PHP libraries using your favorite package manager.
you can always find the latest version. Writing this tutorial, version 1.10 was the latest.
There, the following packages are available:
Example project: (apf-demopack-*):
Contains all necessary APF files and some examples. It's designed for beginners.
Framework code release: (apf-codepack-*):
This contains all necessary APF files. It is designed for daily use.
Sample configuration package: (apf-configpack-*):
This contains some sample configurations, which are useful while creating the own configurations.
For this tutorial we will use the "framework code release", which you can download now.
You need to understand the structure of the folders first. This tutorial expects the document root
(the folder which is being opened when you visit http://localhost/
in your browser) under
The APF is designed delivering a website using only one file. This file (e.g. index.php
called "bootstrap" file. We create the folder /xampp/htdocs/APF/sites/helloworld/
Here you can further place public accessible files (e.g. pictures).
For security reasons the APF files should not be public accessible, otherwise the public might read
your configuration files. The best way would be, placing the package above the document root. If that's
not possible (e.g. on a simple webspace without control of the document root) follow step 4.2, where
a special security rule is being created, otherwise follow step 4.1.
Because the document root is placed at /xampp/htdocs/
, we will create /xampp/APF/
Now we extract the before downloaded package in here.
Now there should be the following directory structure:
If everything is fine, you can skip section 4.2.
We need to take care that we secure the APF files from public requests. We already created
, so we just extract the before downloaded package in here. Now there
should be the following directory structure:
For securing the APF files, we create a .htaccess
using the following content:
# Deny all requests
deny from all
When uploading the .htaccess file via FTP you need to make sure that ASCII-mode is enabled,
otherwise there could be problems.
We dont provide always the full path from now on. We will now call /apps/ the folder
with the APF files, and /APF/ the public accessible folder.
Let's explain the folders first:
/apps/core/: Contains all important APF base libs.
/apps/modules: Contains some optional modules which are provided together
with the APF. If you want to use them, you need to configure them first. How this works can be
read in the tutorials on the
overview page of built-in modules.
/apps/tools: Contains some little but useful tools.
We will create the file /APF/sites/helloworld/index.php
now. We will write
a simple "hello world!" application, in order to explain the base functions.
Hereafter the term namespace will be used instead of folder. The reason for
this is the following: The namespace is a relative addressing from the /apps
folder. In the namespace all "/" must be replaced with "::".
We now need to create the namespace for the template. For that reason we will create the folder
, and in this we create the folders
. Because the APF supports 3 layer applications (presentation,
business and data) the pres
means the presentation layer, in which the
templates are stored in /templates
. We only need one
template for this example:
We just write
Now we edit the before created index.php. It will contain the following: (Description follows below):
// include page controller (for the under 4.1 configured folder)
// include page controller (for the under 4.2 configured folder)
// include and configure the front controller
$fC = &Singleton::getInstance('Frontcontroller');
// start request processing and send result to the client
echo $fC->start('sites::helloworld::pres::templates', 'helloworld');
At first we include the front controller. Here you need to choose the right variation
for the step you followed before. Then we create the front controller instance. Thereafter, the
the template we have created is passed as root template and the front controller is started. The
first parameter is the namespace, the second one is the path to the template with the name of the
template file. File names are always provides without extensions in the APF, because the framework
convention tells how they have to be called (*.html for templates, *.ini for configuration files,
*.php for PHP-files). At last the transform page is displayed by an echo.
The exact function of the front controller can be read about on the Front controller page.
To see the result we visit
There should be displayed Hello World!
Now the base functionality of the APF should be clear. In order to get to know the many other
functions, you should read some more tutorials. I suggest the My first website tutorial as a next step.
This article was exclusively written for adventure-php-framework.org.
Ralf Schubert, an enthusiastic APF developer likes the framework giving the chance
to easily develop reusable gui elements (aka. widgets). This is one of the reasons, why he had
chosen the APF to be his application development framework of choice.
To support beginners, he wrote this article to give a brief introduction into the framework and to
ease the first steps using the APF.
Do you want to add a comment to the article above, or do you want to post additional hints? So please click
Comments already posted can be found below.
thanks for your hint, the text has been corrected. Besides: was this tutorial a useful introduction to you?
otherwise follow steop 4.1 ->
otherwise follow step 4.1