Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

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 ?



7.7k
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



1.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.