Hello world!

1. Introduction

The present chapter describes a "quick&dirty" way to build a "hello world!" application with the Adventure PHP Framework. The My first website tutorial explains - based on this hello world! example - an easy example of a website. The forum thread APF-Modul erstellen (German) and the Objektorientierte Implementierung eines Gästebuchs (German) article provide more complex application samples.

2. Build the "hello world!" application

In order to display the ordinary "hello world!" text a master template must be created. The template file will be stored under apps/sites/helloworld/pres/templates/ as described in the Basics section and gets the name helloworld.html. The structure of the sites/helloworld folder contains the folder pres to store all contents belonging to the presentation layer and the templates sub folder to store the templates files of the web page or application.

Please note, that this structure is only best practice. Using the APF the developer is always free to create his own folder structure!

The template mentioned above contains the legendary sentence:

Code
Hallo Welt! / Hello world!

To do the output, a PHP file must be created. This file is named index.php for now and must be callable via HTTP. The content of the PHP file must be:

PHP code
// include the page controller (APF core library) include_once('./apps/core/pagecontroller/pagecontroller.php'); // include the front controller import('core::frontcontroller', 'Frontcontroller'); // create and configure front controller $fC = &Singleton::getInstance('Frontcontroller'); // start request processing and send result to the client echo $fC->start('sites::helloworld::pres::templates', 'helloworld');

If you now call the index.php file, the text "Hallo Welt! / Hello world!" will be displayed.

With it a program executable under the framework was already provided. To intensify the content, a document controller must be defined which fills the contents of the site as desired. More on controllers can be found on the (Document-)Controller chapter.

Comments

Do you want to add a comment to the article above, or do you want to post additional hints? So please click here. Comments already posted can be found below.
There are no comments belonging to this article.