phalcon/incubator

Phalcon\Session\Adapter classes upgrade

Closed this issue · 4 comments

Following those guidelines https://docs.phalcon.io/4.0/en/session#custom, I listed those breaking changes :

  • The namespace of extended class is wrong
  • Methods : parent::_construct, isStarted, getId, getOptions (and property connection ?) belong to a Manager, not adapter
  • Method open don't respect interface

I did my own adapter/manager in the meantime, hope you'll have time to implement the upgrade as we use your Database adapter in our app 🙏

Work in progress

https://github.com/phalcon/incubator-session

If you need really NOW, you can use master branch, DB adapter already updated.
But things will change for constructor, so be careful. Pick specific commit in your composer.json

oh, such a good idea to use a side project for that. Didn't notice it. I'll test it tomorrow. Thank you for your response

$di->set('session', function () {
    // Create a connection
    $connection = new Mysql([
        'host'     => 'localhost',
        'username' => 'root',
        'password' => 'secret',
        'dbname'   => 'test',
    ]);

    $session = new Database($connection, 'session_data');
    $session->start();

    return $session;
});

I think you missed a doc update. It's still different from Phalcon guidelines, and the start method doesn't even exist.

If I'm not wrong, it should be :

$di->set('session', function () {
    // Create a connection
    $connection = new Mysql([
        'host'     => 'localhost',
        'username' => 'root',
        'password' => 'secret',
        'dbname'   => 'test',
    ]);

    $sessionManager = new \Phalcon\Session\Manager();
    $sessionManager->setAdapter(new Database(connection, 'session_data' ));
    $sessionManager->start();

    return $sessionManager;
});