Hello!
I have a weird problem where my bootstrap file is run twice. I discovered this since I'm logging errors in the DB, and if I throw an error, two records appear in the database.
I'm not sure how this error occurs, so I'd like some help figuring out. My entire app looks like this right now (no controllers, no views, nothing else) except for the LogError model, which is really simple:
<?php
// Define constants.
if(!defined("APPLICATION_PATH")) {
define("APPLICATION_PATH", realpath(__DIR__ . "/../App"));
}
include APPLICATION_PATH . "/configs/config.php";
try {
// Load configuration
$config = new \Phalcon\Config($config);
# Loader
$loader = new \Phalcon\Loader();
# Register namespaces
$loader->registerNamespaces(
array(
'App' => APPLICATION_PATH . "/"
)
);
# Execute loader registration
$loader->register();
# Dependency Injector
$dependencyInjector = new \Phalcon\DI\FactoryDefault();
# Make config available throughout system.
$dependencyInjector->set('config', function() use ($config) {
return $config;
});
# Dispatcher
$dependencyInjector->set('dispatcher', function() use ($dependencyInjector) {
$eventsManager = $dependencyInjector->getShared('eventsManager');
$dispatcher = new \Phalcon\Mvc\Dispatcher();
$dispatcher->setEventsManager($eventsManager);
return $dispatcher;
});
$application = new \Phalcon\Mvc\Application();
$application->setDI($dependencyInjector);
# Force error for trouble shooting.
throw new \Exception("Forced error.");
#echo $application->handle()->getContent();
} catch(\Exception $e) {
$log = new \App\Models\LogError();
$log->message = $e->getMessage();
$log->save();
}
For your reference, my access.log only logs one request, so there must be some kind of redirect in Phalcon running.
Best, dimhoLt