/** * @expectedException \Symfony\Component\Debug\Exception\DummyException */ public function testStacking() { // the ContextErrorException must not be loaded to test the workaround // for https://bugs.php.net/65322. if (class_exists('Symfony\\Component\\Debug\\Exception\\ContextErrorException', false)) { $this->markTestSkipped('The ContextErrorException class is already loaded.'); } $exceptionHandler = $this->getMock('Symfony\\Component\\Debug\\ExceptionHandler', array('handle')); set_exception_handler(array($exceptionHandler, 'handle')); $that = $this; $exceptionCheck = function ($exception) use($that) { $that->assertInstanceOf('Symfony\\Component\\Debug\\Exception\\ContextErrorException', $exception); $that->assertEquals(E_STRICT, $exception->getSeverity()); $that->assertStringStartsWith(__FILE__, $exception->getFile()); $that->assertRegexp('/^Runtime Notice: Declaration/', $exception->getMessage()); }; $exceptionHandler->expects($this->once())->method('handle')->will($this->returnCallback($exceptionCheck)); ErrorHandler::register(); try { // Trigger autoloading + E_STRICT at compile time // which in turn triggers $errorHandler->handle() // that again triggers autoloading for ContextErrorException. // Error stacking works around the bug above and everything is fine. eval(' namespace ' . __NAMESPACE__ . '; class ChildTestingStacking extends TestingStacking { function foo($bar) {} } '); } catch (\Exception $e) { restore_error_handler(); restore_exception_handler(); throw $e; } restore_error_handler(); restore_exception_handler(); }
/** * @return void * @author Michaël VEROUX */ public function boot() { if ('prod' === $this->container->getParameter('kernel.environment')) { $handler = ErrorHandler::register(); $handler->setExceptionHandler(array($this, 'handle')); } }
/** * Registers the autoloader and necessary components. * * @param string $name Name for this application. * @param string|null $version Version number for this application. * @param string|null $environment The environment. */ public function __construct($name, $version = null, $environment = self::ENV_PROD) { parent::__construct($environment); $app = $this; $this['session.test'] = true; $this['console'] = $this->share(function () use($name, $version) { return new Console\Application($name, $version); }); $this['dispatcher'] = $this->share($this->extend('dispatcher', function (EventDispatcher $dispatcher, Application $app) { $dispatcher->addListener('phraseanet.notification.sent', function () use($app) { $app['swiftmailer.spooltransport']->getSpool()->flushQueue($app['swiftmailer.transport']); }); $dispatcher->addSubscriber(new BridgeSubscriber($app)); return $dispatcher; })); $this->register(new PluginServiceProvider()); $this->register(new WebsocketServerServiceProvider()); $this->register(new ComposerSetupServiceProvider()); $this->register(new CLIDriversServiceProvider()); $this->register(new LessBuilderServiceProvider()); $this->register(new SignalHandlerServiceProvider()); $this->register(new TaskManagerServiceProvider()); $this->register(new TranslationExtractorServiceProvider()); $this->register(new DoctrineMigrationServiceProvider()); $this->bindRoutes(); error_reporting(-1); ErrorHandler::register(); PhraseaCLIExceptionHandler::register(); }
public function testStacking() { // the ContextErrorException must not be loaded to test the workaround // for https://bugs.php.net/65322. if (class_exists('Symfony\\Component\\Debug\\Exception\\ContextErrorException', false)) { $this->markTestSkipped('The ContextErrorException class is already loaded.'); } ErrorHandler::register(); try { // Trigger autoloading + E_STRICT at compile time // which in turn triggers $errorHandler->handle() // that again triggers autoloading for ContextErrorException. // Error stacking works around the bug above and everything is fine. eval(' namespace ' . __NAMESPACE__ . '; class ChildTestingStacking extends TestingStacking { function foo($bar) {} } '); $this->fail('ContextErrorException expected'); } catch (\ErrorException $exception) { // if an exception is thrown, the test passed restore_error_handler(); restore_exception_handler(); $this->assertEquals(E_STRICT, $exception->getSeverity()); $this->assertStringStartsWith(__FILE__, $exception->getFile()); $this->assertRegexp('/^Runtime Notice: Declaration/', $exception->getMessage()); } catch (\Exception $e) { restore_error_handler(); restore_exception_handler(); throw $e; } }
public function bootstrap() { $app = $this; $app['dir.base'] = __DIR__ . "/../../../../"; $app->register(new ConfigServiceProvider()); $app['debug'] = $app['config']['debug']; ErrorHandler::register(); ExceptionHandler::register($app['debug']); $app->register(new HttpFragmentServiceProvider()); $app->register(new ServiceControllerServiceProvider()); $app->register(new ORMServiceProvider()); $app->register(new SessionServiceProvider()); $app->register(new SecurityServiceProvider()); $app['security.encoder.digest'] = function ($app) { // uses the password-compat encryption return new BCryptPasswordEncoder(10); }; $app->register(new ManagerRegistryServiceProvider()); $app['security.firewalls'] = array('default' => array('pattern' => '/', 'form' => array('login_path' => '/login', 'check_path' => '/login_check'), 'logout' => array('logout_path' => '/logout', 'invalidate_session' => true), 'users' => function () use($app) { return new EntityUserProvider($app['manager_registry'], User::class, 'username'); }, 'anonymous' => true)); $app['security.access_rules'] = [['^/admin', 'ROLE_ADMIN']]; $app->register(new TranslationServiceProvider(), array('locale_fallbacks' => array('en'), 'locale' => 'en')); $app->register(new ValidatorServiceProvider()); $app->register(new FormServiceProvider()); $app->register(new TwigServiceProvider(), ['twig.path' => __DIR__ . '/../resources/views', 'twig.form.templates' => ['bootstrap_3_layout.html.twig'], 'twig.strict_variables' => false]); $app->extend('twig', function (\Twig_Environment $twig) { $twig->addTest(new \Twig_SimpleTest('callable', function ($variable) { return is_callable($variable); })); $twig->addFunction(new \Twig_SimpleFunction('is_callable', function ($variable) { return is_callable($variable); })); $twig->addFunction(new \Twig_SimpleFunction('call_user_func', function ($callable, $params = null) { return call_user_func($callable, $params); })); $twig->getExtension('core')->setDateFormat('Y/m/d', '%d days'); return $twig; }); $app->extend('form.types', function ($types) use($app) { $types[] = new EntityType($app['manager_registry']); $types[] = new TemplateChoiceType($app['theme']); $types[] = new PageType($app['theme']); return $types; }); $app->register(new SerializerServiceProvider()); $app->register(new WebProfilerServiceProvider(), ['profiler.cache_dir' => './../storage/framework/cache/profiler', 'web_profiler.debug_toolbar.enable' => $app['debug'], 'profiler.mount_prefix' => '/admin/_profiler']); $app['finder'] = function () { return new Finder(); }; $app['filesystem'] = function () { return new Filesystem(); }; $app->register(new ConverterServiceProvider()); $app->register(new ThemeServiceProvider()); $app['twig.loader.filesystem']->addPath($app['dir.theme'], 'theme'); $app->register(new CMSServiceProvider()); $app->setRoutes(); }
public function register(Application $app) { $debug = isset($app['config']) ? $app['config']['app.debug'] : true; $handler = ExceptionHandler::register($debug); ErrorHandler::register(E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR | E_RECOVERABLE_ERROR); if ($cli = $app->runningInConsole() or $debug) { ini_set('display_errors', 1); } $app['exception'] = $handler; }
/** * Constructor */ public function __construct() { // handle errors as exceptions ErrorHandler::register(); // views if (class_exists('\\JpGraph\\JpGraph')) { foreach (array('png', 'jpeg', 'jpg', 'gif') as $format) { self::$viewMapping[$format] = 'Volkszaehler\\View\\JpGraph'; } } }
public function __construct() { parent::__construct(); // Convert errors to exceptions ErrorHandler::register(); ExceptionHandler::register(); $this['cache.directory'] = __DIR__ . '/../../../app/cache'; $this['vendor.directory'] = __DIR__ . '/../../../vendor'; $this->registerControllers(); $this->registerServiceProviders(); $this->registerInternalServices(); }
public function register(Application $app) { ErrorHandler::register(); ExceptionHandler::register($app['debug']); $app->error(function (\Exception $exception, $code) use($app) { if (!$app['debug'] || $code === 404) { // 404.html, or 40x.html, or 4xx.html, or error.html $templates = array('errors/' . $code . '.html.twig', 'errors/' . substr($code, 0, 2) . 'x.html.twig', 'errors/' . substr($code, 0, 1) . 'xx.html.twig', 'errors/' . 'default.html.twig'); return new Response($app['twig']->resolveTemplate($templates)->render(array('code' => $code)), $code); } }); }
public static function run() { // Converts warnings to exceptions ErrorHandler::register(); $config = self::loadConfig(); $container = new Container($config['extensions']); unset($config['extensions']); $container->configure(); $container->mergeParameters($config); $container->build(); $container->get('console.application')->run(); }
public function __construct($config = array()) { parent::__construct($config); ErrorHandler::register(); // JSON/REST application $this->register(new ContentNegotiationServiceProvider(), array("conneg.responseFormats" => array("json"), "conneg.requestFormats" => array("json"), "conneg.defaultFormat" => "json")); $this->register(new CorsServiceProvider()); // JSON Schema application $this->register(new JsonSchemaServiceProvider()); // Error Handling $this->error(new JsonErrorHandler($this)); }
/** * Sets error reporting */ public function setErrorReporting() { if (true === $this->_config->getConfigData('development_environment')) { error_reporting(E_ALL); ini_set('display_errors', 'On'); ErrorHandler::register(); } else { error_reporting(E_ALL); ini_set('display_errors', 'Off'); ini_set('log_errors', 'On'); ini_set('error_log', ROOT . DS . 'tmp' . DS . 'logs' . DS . 'error.log'); } }
public function boot() { ErrorHandler::register(null, false)->throwAt($this->container->getParameter('debug.error_handler.throw_at'), true); if ($trustedProxies = $this->container->getParameter('kernel.trusted_proxies')) { Request::setTrustedProxies($trustedProxies); } if ($this->container->getParameter('kernel.http_method_override')) { Request::enableHttpMethodParameterOverride(); } if ($trustedHosts = $this->container->getParameter('kernel.trusted_hosts')) { Request::setTrustedHosts($trustedHosts); } }
public static function enable($environment = 'dev') { if (static::$enabled) { return; } static::$enabled = true; error_reporting(-1); // Beware, ExceptionHandler::register and ErrorHandler::register must be called in this order // to fatal errors handling work ExceptionHandler::register(true, $environment); ErrorHandler::register(); DebugClassLoader::enable(); }
/** * Enables the debug tools. * * This method registers an error handler and an exception handler. * * If the Symfony ClassLoader component is available, a special * class loader is also registered. * * @param integer $errorReportingLevel The level of error reporting you want * @param Boolean $displayErrors Whether to display errors (for development) or just log them (for production) */ public static function enable($errorReportingLevel = null, $displayErrors = true) { if (static::$enabled) { return; } static::$enabled = true; error_reporting(-1); ErrorHandler::register($errorReportingLevel, $displayErrors); if ('cli' !== php_sapi_name()) { ExceptionHandler::register(); // CLI - display errors only if they're not already logged to STDERR } elseif ($displayErrors && (!ini_get('log_errors') || ini_get('error_log'))) { ini_set('display_errors', 1); } DebugClassLoader::enable(); }
/** * Loads third party libraries. * * @since 1.1.0 * * @author Eddilbert Macharia (http://eddmash.com) <*****@*****.**> */ public static function loadThirdParty() { $ds = DIRECTORY_SEPARATOR; $vendorDir = sprintf('%1$s%2$svendor%2$s', HOMEPATH, $ds); if (file_exists($vendorDir . 'doctrine')) { $path = '%1$sdoctrine%2$scommon%2$slib%2$sDoctrine%2$sCommon%2$sClassLoader.php'; require sprintf($path, $vendorDir, $ds); $commonLoader = new \Doctrine\Common\ClassLoader('Doctrine', $vendorDir . 'doctrine' . $ds . 'common' . $ds . 'lib'); $commonLoader->register(); $dbalLoader = new \Doctrine\Common\ClassLoader('Doctrine', $vendorDir . 'doctrine' . $ds . 'dbal' . $ds . 'lib'); $dbalLoader->register(); } if (file_exists($vendorDir . $ds . 'symfony' . $ds . 'debug')) { ErrorHandler::register(); } }
/** * Enables the debug tools. * * This method registers an error handler and an exception handler. * * If the Symfony ClassLoader component is available, a special * class loader is also registered. * * @param integer $errorReportingLevel The level of error reporting you want */ public static function enable($errorReportingLevel = null) { if (static::$enabled) { return; } static::$enabled = true; error_reporting(-1); ErrorHandler::register($errorReportingLevel); if ('cli' !== php_sapi_name()) { ExceptionHandler::register(); } elseif (!ini_get('log_errors') || ini_get('error_log')) { ini_set('display_errors', 1); } if (class_exists('Symfony\\Component\\ClassLoader\\DebugClassLoader')) { DebugClassLoader::enable(); } }
/** * Sets default exception handler. * * If shop is in productive mode stick to default OXID exception handler * Else register Symfony Debug component's Exception and Error handlers * * Non-productive eShop mode is intended for eShop installation, configuration, template customization and module debugging phase. * As soon as productive mode is turned ON, the cache handling and the error reporting behavior is optimized for the live shop. */ protected function _setDefaultExceptionHandler() { /** * @todo: consider also getEnvironment() function to detect environment */ if (oxRegistry::getConfig()->isProductiveMode()) { parent::_setDefaultExceptionHandler(); return; } /** * Debug::enable() also registers a DebugClassLoader which throw an error because oxid does not care about case when referring to objects * symfony is key sensitive: oxarticlelist != oxArticleList */ //Debug\Debug::enable(); ini_set('display_errors', 0); Debug\ExceptionHandler::register(); Debug\ErrorHandler::register()->throwAt(0, true); }
/** * Enables the debug tools. * * This method registers an error handler and an exception handler. * * If the Symfony ClassLoader component is available, a special * class loader is also registered. * * @param int $errorReportingLevel The level of error reporting you want * @param bool $displayErrors Whether to display errors (for development) or just log them (for production) */ public static function enable($errorReportingLevel = null, $displayErrors = true) { if (static::$enabled) { return; } static::$enabled = true; error_reporting(-1); ErrorHandler::register($errorReportingLevel, $displayErrors); if ('cli' !== PHP_SAPI) { ExceptionHandler::register(); // CLI - display errors only if they're not already logged to STDERR } elseif ($displayErrors && (!ini_get('log_errors') || ini_get('error_log'))) { ini_set('display_errors', 1); } if (class_exists('Symfony\\Component\\ClassLoader\\DebugClassLoader')) { DebugClassLoader::enable(); } }
/** * Init config * * @param Application $app */ private function _iniConfig(Application $app) { // Setting the sign of the console $app['is_console'] = TRUE; // Load configurations $app->register(new Providers\YamlConfigServiceProvider(array('%base_path%' => BASEPATH, '%log_path%' => BASEPATH . '/data/logs', '%cache_path%' => BASEPATH . '/data/cache')), array('config.dir' => BASEPATH . '/app/Resources/Config', 'config.files' => array('console.yml'))); //Set debug option $app['debug'] = $app['config']['parameters']['debug']; //Set basepath option $app['basepath'] = $this->app['config']['base_path']; //Set Timezone if (isset($app['config']['parameters']['timezone'])) { date_default_timezone_set($app['config']['parameters']['timezone']); } // Registering the ErrorHandler // It converts all errors to exceptions, and exceptions are then caught by Silex ErrorHandler::register(); ExceptionHandler::register($app['debug']); }
/** * Set the handlers. * * @param bool $debug */ public static function register($debug = true) { $errorLevels = error_reporting(); if ($debug) { $errorLevels |= E_RECOVERABLE_ERROR | E_USER_ERROR | E_DEPRECATED | E_USER_DEPRECATED; Debug\DebugClassLoader::enable(); } if (PHP_SAPI !== 'cli') { Debug\ErrorHandler::register()->throwAt($errorLevels, true); Debug\ExceptionHandler::register($debug); } else { $consoleHandler = function (\Exception $e) { $app = new Application('Bolt CLI', Version::VERSION); $output = new ConsoleOutput(OutputInterface::VERBOSITY_DEBUG); $app->renderException($e, $output); ob_clean(); }; Debug\ExceptionHandler::register($debug)->setHandler($consoleHandler); } }
public static function run(ClassLoader $autoloader) { // Converts warnings to exceptions ErrorHandler::register(); $config = self::loadConfig(); if (isset($config['extension_autoloader']) && $config['extension_autoloader']) { $autoloadFile = $config['extension_autoloader']; if (!file_exists($autoloadFile)) { throw new \InvalidArgumentException(sprintf('Could not find extension autoload file "%s"', $autoloadFile)); } $autoloader->unregister(); include $autoloadFile; $autoloader->register(true); } $extensions = $config['extensions']; $extensions[] = 'PhpBench\\Extension\\CoreExtension'; unset($config['extensions']); $container = new Container($extensions, $config); $container->init(); $container->get('console.application')->run(); }
public function testHandle() { $handler = ErrorHandler::register(0); $this->assertFalse($handler->handle(0, 'foo', 'foo.php', 12, 'foo')); restore_error_handler(); $handler = ErrorHandler::register(3); $this->assertFalse($handler->handle(4, 'foo', 'foo.php', 12, 'foo')); restore_error_handler(); $handler = ErrorHandler::register(3); try { $handler->handle(111, 'foo', 'foo.php', 12, 'foo'); } catch (\ErrorException $e) { $this->assertSame('111: foo in foo.php line 12', $e->getMessage()); $this->assertSame(111, $e->getSeverity()); $this->assertSame('foo.php', $e->getFile()); $this->assertSame(12, $e->getLine()); } restore_error_handler(); $handler = ErrorHandler::register(E_USER_DEPRECATED); $this->assertTrue($handler->handle(E_USER_DEPRECATED, 'foo', 'foo.php', 12, 'foo')); restore_error_handler(); $handler = ErrorHandler::register(E_DEPRECATED); $this->assertTrue($handler->handle(E_DEPRECATED, 'foo', 'foo.php', 12, 'foo')); restore_error_handler(); $logger = $this->getMock('Psr\\Log\\LoggerInterface'); $that = $this; $warnArgCheck = function ($message, $context) use($that) { $that->assertEquals('foo', $message); $that->assertArrayHasKey('type', $context); $that->assertEquals($context['type'], ErrorHandler::TYPE_DEPRECATION); $that->assertArrayHasKey('stack', $context); $that->assertInternalType('array', $context['stack']); }; $logger->expects($this->once())->method('warning')->will($this->returnCallback($warnArgCheck)); $handler = ErrorHandler::register(E_USER_DEPRECATED); $handler->setLogger($logger); $handler->handle(E_USER_DEPRECATED, 'foo', 'foo.php', 12, 'foo'); restore_error_handler(); }
public function testRedirectDoesNotRaisePHPNoticesWhenMonologIsRegistered() { $app = new Application(); ErrorHandler::register(); $app['monolog.logfile'] = 'php://memory'; $app->register(new MonologServiceProvider()); $app->get('/foo/', function () { return 'ok'; }); $response = $app->handle(Request::create('/foo')); $this->assertEquals(301, $response->getStatusCode()); }
public function testHandleFatalErrorOnHHVM() { try { $handler = ErrorHandler::register(); $logger = $this->getMock('Psr\\Log\\LoggerInterface'); $logger->expects($this->once())->method('log')->with($this->equalTo(LogLevel::CRITICAL), $this->equalTo('Fatal Error: foo'), $this->equalTo(array('type' => 1, 'file' => 'bar', 'line' => 123, 'level' => -1, 'stack' => array(456)))); $handler->setDefaultLogger($logger, E_ERROR); $error = array('type' => E_ERROR + 0x1000000, 'message' => 'foo', 'file' => 'bar', 'line' => 123, 'context' => array(123), 'backtrace' => array(456)); call_user_func_array(array($handler, 'handleError'), $error); $handler->handleFatalError($error); restore_error_handler(); restore_exception_handler(); } catch (\Exception $e) { restore_error_handler(); restore_exception_handler(); throw $e; } }
<?php ini_set('display_errors', 0); require_once __DIR__ . '/../vendor/autoload.php'; use Symfony\Component\Debug\Debug; use Symfony\Component\Debug\ErrorHandler; use Symfony\Component\Debug\ExceptionHandler; $debug = getenv('APP_DEBUG'); if ('cli' !== php_sapi_name()) { ExceptionHandler::register(); } if ($debug) { ErrorHandler::register(null, true); ini_set('display_errors', 1); error_reporting(-1); Debug::enable(); } $app = (require __DIR__ . '/../src/app.php'); $app->run();
<?php use Symfony\Component\Debug\ErrorHandler; use Symfony\Component\Debug\ExceptionHandler; require_once __DIR__ . '/../vendor/autoload.php'; $app = (require __DIR__ . '/../src/app.php'); ErrorHandler::register(); ExceptionHandler::register(); require __DIR__ . '/../config/dev.php'; require __DIR__ . '/../src/Http/Routes.php'; $app['capsule']; $app->run();
/** * @group legacy */ public function testLegacyInterface() { try { $handler = ErrorHandler::register(0); $this->assertFalse($handler->handle(0, 'foo', 'foo.php', 12, array())); restore_error_handler(); restore_exception_handler(); $logger = $this->getMock('Psr\\Log\\LoggerInterface'); $that = $this; $logArgCheck = function ($level, $message, $context) use($that) { $that->assertEquals('Undefined variable: undefVar', $message); $that->assertArrayHasKey('type', $context); $that->assertEquals($context['type'], E_NOTICE); }; $logger->expects($this->once())->method('log')->will($this->returnCallback($logArgCheck)); $handler = ErrorHandler::register(E_NOTICE); @$handler->setLogger($logger, 'scream'); unset($undefVar); @$undefVar++; restore_error_handler(); restore_exception_handler(); } catch (\Exception $e) { restore_error_handler(); restore_exception_handler(); throw $e; } }
<?php declare (strict_types=1); /* * This file is part of the SkeletonDancer package. * * (c) Sebastiaan Stok <*****@*****.**> * * This source file is subject to the MIT license that is bundled * with this source code in the file LICENSE. */ require __DIR__ . '/../vendor/autoload.php'; use Rollerworks\Tools\SkeletonDancer\Cli\DancerApplicationConfig; \Symfony\Component\Debug\ErrorHandler::register(); \Symfony\Component\Debug\DebugClassLoader::enable(); $cli = new \Webmozart\Console\ConsoleApplication(new DancerApplicationConfig()); $cli->run();
public function initialise() { // File System $this->registry->set('filesystem', new Filesystem()); // Config $this->registry->set('config', new Config()); // Database $this->registry->set('db', new DB(DB_DRIVER, DB_HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_DATABASE)); // Store if (isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on' || $_SERVER['HTTPS'] == '1')) { $store_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "store WHERE REPLACE(`ssl`, 'www.', '') = '" . $this->db->escape('https://' . str_replace('www.', '', $_SERVER['HTTP_HOST']) . rtrim(dirname($_SERVER['PHP_SELF']), '/.\\') . '/') . "'"); } else { $store_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "store WHERE REPLACE(`url`, 'www.', '') = '" . $this->db->escape('http://' . str_replace('www.', '', $_SERVER['HTTP_HOST']) . rtrim(dirname($_SERVER['PHP_SELF']), '/.\\') . '/') . "'"); } if ($store_query->num_rows) { $this->config->set('config_store_id', $store_query->row['store_id']); } else { $this->config->set('config_store_id', 0); } // Settings $query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "setting` WHERE store_id = '0' OR store_id = '" . (int) $this->config->get('config_store_id') . "' ORDER BY store_id ASC"); foreach ($query->rows as $result) { if (!$result['serialized']) { $this->config->set($result['key'], $result['value']); } else { $this->config->set($result['key'], unserialize($result['value'])); } } if (!$store_query->num_rows) { $this->config->set('config_url', HTTP_SERVER); $this->config->set('config_ssl', HTTPS_SERVER); } // Loader $this->registry->set('load', new Loader($this->registry)); // Trigger $this->registry->set('trigger', new Trigger($this->registry)); // Url $this->registry->set('url', new Url($this->config->get('config_url'), $this->config->get('config_ssl'), $this->registry)); // Uri $this->registry->set('uri', new Uri()); // Log $this->registry->set('log', new Log($this->config->get('config_error_filename'))); // Error Handler if ($this->config->get('config_error_display', 0) == 2) { ErrorHandler::register(); ExceptionHandler::register(); } else { set_error_handler(array($this, 'errorHandler')); } // Security $this->registry->set('security', new Security($this->registry)); // Request $this->registry->set('request', new Request($this->registry)); // Response $response = new Response(); $response->addHeader('Content-Type: text/html; charset=utf-8'); $response->setCompression($this->config->get('config_compression')); $this->registry->set('response', $response); // Cache $cache = new Cache($this->config->get('config_cache_storage', 'file'), $this->config->get('config_cache_lifetime', 86400)); $this->registry->set('cache', $cache); // Session $this->registry->set('session', new Session()); // Utility $utility = new Utility($this->registry); $this->registry->set('utility', $utility); // Language Detection $language = $utility->getLanguage(); if (!isset($this->session->data['language']) || $this->session->data['language'] != $language['code']) { $this->session->data['language'] = $language['code']; } if (!isset($this->request->cookie['language']) || $this->request->cookie['language'] != $language['code']) { setcookie('language', $language['code'], time() + 60 * 60 * 24 * 30, '/', $this->request->server['HTTP_HOST']); } $this->config->set('config_language', $language['code']); $this->config->set('config_language_dir', $language['directory']); $this->config->set('config_language_id', $language['language_id']); // Language $this->registry->set('language', new Language($language['directory'], $this->registry)); // Page Cache $pagecache = new Pagecache($this->registry); $pagecache->getPage(); $this->registry->set('pagecache', $pagecache); // Document $this->registry->set('document', new Document()); $this->trigger->fire('post.app.initialise'); }