The Adventure PHP Framework (briefly: APF) is designed to assist the developer with the implementation of object oriented and reusable PHP based web applications. It makes use of and implements several important object oriented design patterns and offers a large set of solutions for day-2-day tasks.
The APF is no complete and ready-to-use application that only needs to be configured prior to run but a strong basis to create such application easily and using common software development procedures.
As other PHP frameworks the APF follows dedicated principles and paradigms. The following list contains a list of the most important ones:
The following chapters contain basic topics on the APF.
The Adventure PHP Framework is a framework written for PHP to develop web applications. For this reason you need a web server including the PHP module. You may want to use the de-facto standard Apache HTTP Server or nginx respectively.
The APF 2.X requires PHP > 5.3.0 since it is based on PHP namespaces. APF 1.X also works with Version less than 5.3.0. Well-known packages such as XAMPP already contain the required PHP version.
In order to quick-start with the framework it is recommended to download a apf-demopack-* file. These files do not only contain the APF code but a ready-to-use example web site - the Sandbox. The Sandbox contains a large number of examples and wizards to get familiar with the APF. In case you don't have experience with the APF yet, the Sandbox can also be used as a development environment for custom modules or components. Later on, they can be easily integrated into your own web site.
To gain efficiency while programming the APF team strongly recommends to use PHPStorm. It contains code completion, direct feedback on coding issues and a decent integration of xdebug to analyze errors within your application.
Now it's up to you! With the above tools you are now well-equipped to start with development!
Under Downloads you can find the downloads of the current release and a reference on experimental versions (see GIT repository). If you are looking for current snapshots, please refer to GIT repository.
The documentation of the framework is located under Documentation. There are the following areas: the Components documentation with a separate chapter on each component, the Tutorials and the Articles section with further information on the framework and software development in common.
The Adventure PHP Framework has four main areas: the core that contains basic components, the tools area that ships components that ease development and the modules and extensions section that include ready-to-use modules or extensions.
Each release includes several packages that are all based on the apf-codepack-* files that contains the code base of the APF. Besides, the apf-configpack-* listed under Downloads contains a set of sample content files according to each version.
In case you are searching for implementation samples, you may want to use the Sandbox (package: apf-demopack-*) or the sample packages apf-calc-example-* (simple calculator), apf-modules-example-* (inclusion of dynamic modules), or apf-vbc-example-* - a sample implementation for How to implement view based caching.
As noted in chapter 3 the apf-codepack-* files contain the code base of the Adventure PHP Framework. The package contains the following folders:
APF/ core/ extensions/ modules/ tools/
The core and tools folders contain the core parts of the framework. Within core you can find the implementation of the Page controller (/APF/core/pagecontroller/) and the Front controller (/APF/core/frontcontroller/), having a look at tools you may find the Forms implementation (/APF/tools/form/).
Details on the components can also be taken from the API documentation.
This chapter shows you how to create a very simple page using the apf-codepack-* release file.
As described in chapter 2 the APF uses the boot-strapping concept. This means that the requests of all visitors are handled by one central file (index.php in most cases, bacause this file is configured as DirectoryIndex).
In order to create a simple application please download a apf-codepack-* release file and extract it into a folder located under the DOCUMENT_ROOT of your web server. After that, please create an index.php file in parallel to the APF folder.
Every web page or web application starts with an initial template that takes includes all areas of your application. Please use the following code as a basis for this chapter for the index.php file:
include('./APF/core/bootstrap.php'); use APF\core\singleton\Singleton; use APF\core\frontcontroller\FrontController; $fC = Singleton::getInstance(FrontController::class); echo $fC->start('APF\site\templates', 'main');
Within the first line the APF/core/bootstrap.php is included. This file includes all necessary APF components and does the initial configuration.
Line 5 creates an instance of the Front controller and within the last line the request processing is started by applying the initial template. The echo causes the return value - the content of the entire page - to be sent back to the user.
Templates play a central role within the Adventure PHP Framework. As mentioned in the last chapter each application starts from a basic template and the Page controller uses templates for it's template-centric implementation of the HMVC pattern.
Within the above sample the Front controller is started with the basic template main from the APF\site\templates namespace. Hence, it expects the main.html file to be stored within folder APF/site/templates. The folder structure is thus as follows:
APF/ core/ extensions/ modules/ site/ templates/ main.html tools/
In case you add
My first application with the APF!
to the template file and call the index.php you will be presented the text of the template.
This sample assumes that the standard configuration of the APF has not been changed - especially concerning the ClassLoader configuration. Details on the configuration can be taken from chapter Class loading.
For parameters that are used by various components the framework provides a configuration facility making use of the Registry. In case you intend to adapt those parameters please use the index.php.
The following list shows all relevant parameters from the APF\core namespace:
In case you want to change one or more of the parameters please added the following code to your index.php:
include('./APF/core/bootstrap.php'); use APF\core\registry\Registry; Registry::register('APF\core', 'Environment', 'TEST'); Registry::register('APF\core', 'InternalLogTarget', 'framework'); Registry::register('APF\core', 'Charset', 'UTF-16'); ...