We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Persistent variable return an error in 4.0.0-alpha1

After the last update to 4.0.0-alpha1, my persistent variables return the following error: Service 'sessionBag' wasn't found in the dependency injection container

This happens for example if I try this:

public function indexAction(){
    $this->persistent->direction= "DESC";
} 

Is there a new method for persistent variables ? Should I use a SessionBag instead ?



10.1k
Accepted
answer

Sessionbag is not part of the FactoryDefault anymore. Please check this blog post https://blog.phalcon.io/post/upgrading-to-v4-alpha-1 You can add the sessionBag manualy to the DI



4.1k

Thanks. It removed the error when I added a sessionbag to the di

$di->set(
    'sessionBag',
    function () {
        $session_bag = new SessionBag("sessionBag");
        return $session_bag;
}
);

However, it still seems that I cannot do a $this->persistent->direction="DESC" anymore in my controller class.