Brand new to Phalcon (and frameworks in general) so forgive my n00b-ness.
I want to load my config in my bootstrap file, then have it stored in the session (so it only needs to be loaded once, and accessible globally).
I've got my session being created, and I'm successfully loading my configuration info into $Config. How do I store $Config in the session though? Since I'm not in a controller I can't use $this->session
. It appears the only way is to pull the session out of the DI, add the $config property, then re-set the DI's session property:
$DI->setShared('session', function(){
$session = new Phalcon\Session\Adapter\Files();
if(session_status() == PHP_SESSION_NONE)
$session->start();
return $session;
});
$Config = require '../app/config/config.php';
$Session = $DI->get('session');
$Session->config = $Config;
$DI->setShared('session',$Session);
Though that seems like a pretty inefficient way to store something in the session in the bootstrap. Is this the only way to do it or am I missing some hidden functionality? I suppose I could create the session manually (rather than in the anonymous function), set 'config', then store it with $DI->setShared()
.