Slim3 + eloquent observe + redis

Hello. Help me please…
i want setup event in model for redis cache update when data save
i use native slim3 container but for observe i use Illuminate\Container\Container
becouse i have problem like this https://stackoverflow.com/questions/51506326/is-it-possible-to-use-php-di-definitions-instead-of-eloquents-capsule-managers-b

$container['laravel-container'] = function ($c){
    return new \Illuminate\Container\Container;
};
$container['database-event-dispatcher'] = function ($c) {
    return new \Illuminate\Events\Dispatcher($c['laravel-container']);
};
$capsule->setEventDispatcher($container['database-event-dispatcher'])

next

Dappur\Model\RoomUser::observe(new Dappur\Model\Observers\RoomUserObserver($container));

namespace Dappur\Model\Observers;
use Dappur\Model\RoomUser;
use Interop\Container\ContainerInterface;
use Illuminate\Container\Container;
use Symfony\Component\Cache\Adapter\RedisAdapter;
class RoomUserObserver {
    public $container;
    public function __construct($container) {
        $this->container= $container;		
    }
    public function saved(RoomUser $roomUser) {
    }
}

and i have error

/var/www/roombear/data/www/roombear.ru/vendor/illuminate/container/Container.php
Line: 933
Message: Unresolvable dependency resolving [Parameter #0 [ $container ]] in class Dappur\Model\Observers\RoomUserObserver

where could i make a mistake?
thank you.

Maybe you should give the dependency resolver the information what he has to resolve. For example add Container $container to the constructor (instead of mixed):

use Illuminate\Container\Container;
// ...
public function __construct(Container $container) {

}
1 Like

I have already done so) did not help)
The second day I can not understand why it does not work.)))

if anyone is interested in how I solved the problem.

class RoomObserver {

    static $container = null;

    public function __construct($container = null) {
	
		if(is_null(self::$container)){
			self::$container = $container;			
		}
    }
    public function saved(Room $room) {
    }
}

Hi @kaktus7702 ,

Could you please detail on the steps of integrating Redis Cache with Slim3 and library used in your development. It would help.

I have used memcache in my current development, Now need to integrate REDIS cache as moving towards cloud based redis cache service.

Thanks!