I am trying to add caching to Slim 3, I followed the instruction in https://www.slimframework.com/docs/v3/features/caching.html :
$app = new Slim\App(['settings' => $config]);
$container = $app->getContainer();
$container['cache'] = function () {
return new \Slim\HttpCache\CacheProvider();
};
$app->add(new \Slim\HttpCache\Cache('public', 86400));
but I get the following error :
{
"message": "Slim Application Error",
"exception": [
{
"type": "RuntimeException",
"code": 0,
"message": "{} is not resolvable",
"file": "C:\Users\Mima\Desktop\file\app\server\src\vendor\slim\slim\Slim\CallableResolver.php",
"line": 113,
"trace": [
"#0 C:\Users\Mima\Desktop\file\app\server\src\vendor\slim\slim\Slim\CallableResolver.php(61): Slim\CallableResolver->assertCallable(Object(Slim\HttpCache\Cache))",
"#1 C:\Users\Mima\Desktop\file\app\server\src\vendor\slim\slim\Slim\CallableResolverAwareTrait.php(41): Slim\CallableResolver->resolve(Object(Slim\HttpCache\Cache))",
"#2 C:\Users\Mima\Desktop\file\app\server\src\vendor\slim\slim\Slim\DeferredCallable.php(50): Slim\DeferredCallable->resolveCallable(Object(Slim\HttpCache\Cache))",
"#3 [internal function]: Slim\DeferredCallable->__invoke(Object(Slim\Http\Request), Object(Slim\Http\Response), Object(Slim\App))",
"#4 C:\Users\Mima\Desktop\file\app\server\src\vendor\slim\slim\Slim\MiddlewareAwareTrait.php(70): call_user_func(Object(Slim\DeferredCallable), Object(Slim\Http\Request), Object(Slim\Http\Response), Object(Slim\App))",
"#5 C:\Users\Mima\Desktop\file\app\server\src\classes\middlewares\TrailingSlash.php(29): Slim\App->Slim\{closure}(Object(Slim\Http\Request), Object(Slim\Http\Response))",
"#6 [internal function]: App\Middleware\TrailingSlash->__invoke(Object(Slim\Http\Request), Object(Slim\Http\Response), Object(Closure))",
"#7 C:\Users\Mima\Desktop\file\app\server\src\vendor\slim\slim\Slim\DeferredCallable.php(57): call_user_func_array(Object(App\Middleware\TrailingSlash), Array)",
"#8 [internal function]: Slim\DeferredCallable->__invoke(Object(Slim\Http\Request), Object(Slim\Http\Response), Object(Closure))",
"#9 C:\Users\Mima\Desktop\file\app\server\src\vendor\slim\slim\Slim\MiddlewareAwareTrait.php(70): call_user_func(Object(Slim\DeferredCallable), Object(Slim\Http\Request), Object(Slim\Http\Response), Object(Closure))",
"#10 C:\Users\Mima\Desktop\file\app\server\src\public\index.php(1047): Slim\App->Slim\{closure}(Object(Slim\Http\Request), Object(Slim\Http\Response))",
"#11 [internal function]: Closure->{closure}(Object(Slim\Http\Request), Object(Slim\Http\Response), Object(Closure))",
"#12 C:\Users\Mima\Desktop\file\app\server\src\vendor\slim\slim\Slim\DeferredCallable.php(57): call_user_func_array(Object(Closure), Array)",
"#13 [internal function]: Slim\DeferredCallable->__invoke(Object(Slim\Http\Request), Object(Slim\Http\Response), Object(Closure))",
"#14 C:\Users\Mima\Desktop\file\app\server\src\vendor\slim\slim\Slim\MiddlewareAwareTrait.php(70): call_user_func(Object(Slim\DeferredCallable), Object(Slim\Http\Request), Object(Slim\Http\Response), Object(Closure))",
"#15 C:\Users\Mima\Desktop\file\app\server\src\vendor\slim\slim\Slim\MiddlewareAwareTrait.php(117): Slim\App->Slim\{closure}(Object(Slim\Http\Request), Object(Slim\Http\Response))",
"#16 C:\Users\Mima\Desktop\file\app\server\src\vendor\slim\slim\Slim\App.php(392): Slim\App->callMiddlewareStack(Object(Slim\Http\Request), Object(Slim\Http\Response))",
"#17 C:\Users\Mima\Desktop\file\app\server\src\vendor\slim\slim\Slim\App.php(297): Slim\App->process(Object(Slim\Http\Request), Object(Slim\Http\Response))",
"#18 C:\Users\Mima\Desktop\file\app\server\src\public\index.php(1059): Slim\App->run()",
"#19 {main}"
]
}
]
}