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.

how to rewrite functions in Phalcon\Session\Adapter\Redis

hi all! i want to rewrite functions in Phalcon\Session\Adapter\Redis. so can i do it??? ex: rewrite: public function write(), public function read()... thanks so!



42.3k
Accepted
answer

Sure, create your own class:

class MyRedisAdapter extends \Phalcon\Session\Adapter\Redis
{
    public function write() {
        // ...
    }
    public function read() {
        // ...
    }
}

Then register this as your session adapter in services:

$di->setShared('session', function() {
    $session = new MyRedisAdapter();
    return $session;
});

Yes. Just create your class and extend Phalcon\Session\Adapter\Redis



1.3k

thank you! usefull

Sure, create your own class:

class MyRedisAdapter extends \Phalcon\Session\Adapter\Redis
{
  public function write() {
      // ...
  }
  public function read() {
      // ...
  }
}

Then register this as your session adapter in services:

$di->setShared('session', function() {
  $session = new MyRedisAdapter();
  return $session;
});


1.3k

sorry, can you tell me where is the class MyRedisAdapter place in project??? thanks

Sure, create your own class:

class MyRedisAdapter extends \Phalcon\Session\Adapter\Redis
{
  public function write() {
      // ...
  }
  public function read() {
      // ...
  }
}

Then register this as your session adapter in services:

$di->setShared('session', function() {
  $session = new MyRedisAdapter();
  return $session;
});

Depends on your your project layout, you have to register it with the class loader: https://docs.phalconphp.com/en/latest/reference/loader.html



1.3k

my file structure as example of phalcon and what i should use???

Registering Directories ,Registering Classes, Registering Namespaces! thank you for help!

Depends on your your project layout, you have to register it with the class loader: https://docs.phalconphp.com/en/latest/reference/loader.html