Example #1
0
    $apfClassLoaderRootPath = str_replace('/core', '', str_replace('\\', '/', dirname(__FILE__)));
}
// Manual definition of the configuration root path allows separation of APF source and configuration
// files. By default, configuration files reside under the same root folder.
if (!isset($apfClassLoaderConfigurationRootPath)) {
    $apfClassLoaderConfigurationRootPath = $apfClassLoaderRootPath;
}
// include the class loader
include_once dirname(__FILE__) . '/loader/ClassLoader.php';
include_once dirname(__FILE__) . '/loader/StandardClassLoader.php';
include_once dirname(__FILE__) . '/loader/RootClassLoader.php';
// register class loader before including/configuring further elements
\APF\core\loader\RootClassLoader::addLoader(new \APF\core\loader\StandardClassLoader('APF', $apfClassLoaderRootPath, $apfClassLoaderConfigurationRootPath));
spl_autoload_register(['\\APF\\core\\loader\\RootClassLoader', 'load']);
// register the APF error handler to be able to easily configure the error handling mechanism
GlobalExceptionHandler::registerExceptionHandler(new DefaultExceptionHandler());
GlobalExceptionHandler::enable();
// let PHP raise and display all errors to be able to handle them suitable by the APF error handler.
error_reporting(E_ALL);
ini_set('display_errors', '1');
ini_set('html_errors', 'off');
// register the APF error handler to be able to easily configure the error handling mechanism
GlobalErrorHandler::registerErrorHandler(new DefaultErrorHandler());
GlobalErrorHandler::enable();
// Define base parameters of the framework's core and tools layer
Registry::register('APF\\core', 'Environment', 'DEFAULT');
Registry::register('APF\\core', 'InternalLogTarget', 'apf');
Registry::register('APF\\core', 'Charset', 'UTF-8');
// set up configuration provider to let the developer customize it later on
ConfigurationManager::registerProvider('ini', new IniConfigurationProvider());
// configure logger (outside namespace'd file! otherwise initialization will not work)