Work on API project. Everything good until I have to add a new endpoint (new method too) and I got this Error for my new endpoint, another endpoint run well. Below is error log:
Type: RuntimeException
Message: [{“container”:{}},“getNotification”] is not resolvable
File: /opt/myanime/api/vendor/slim/slim/Slim/CallableResolver.php
Line: 104
Trace
#0 /opt/myanime/api/vendor/slim/slim/Slim/CallableResolver.php(62): SlimCallableResolver->assertCallable(Array)
#1 /opt/myanime/api/vendor/slim/slim/Slim/CallableResolverAwareTrait.php(45): SlimCallableResolver->resolve(‘UserController:…’)
#2 /opt/myanime/api/vendor/slim/slim/Slim/Route.php(333): SlimRoutable->resolveCallable(‘UserController:…’)
#3 /opt/myanime/api/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(122): SlimRoute->__invoke(Object(SlimHttpRequest), Object(SlimHttpResponse))
#4 /opt/myanime/api/vendor/slim/slim/Slim/Route.php(316): SlimRoute->callMiddlewareStack(Object(SlimHttpRequest), Object(SlimHttpResponse))
#5 /opt/myanime/api/vendor/slim/slim/Slim/App.php(476): SlimRoute->run(Object(SlimHttpRequest), Object(SlimHttpResponse))
#6 /opt/myanime/api/src/MyanimeMiddleware.php(121): SlimApp->__invoke(Object(SlimHttpRequest), Object(SlimHttpResponse))
#7 [internal function]: AppMyanimeMiddleware->__invoke(Object(SlimHttpRequest), Object(SlimHttpResponse), Object(SlimApp))
#8 /opt/myanime/api/vendor/slim/slim/Slim/DeferredCallable.php(43): call_user_func_array(Object(AppVestiaMiddleware), Array)
#9 [internal function]: SlimDeferredCallable->__invoke(Object(SlimHttpRequest), Object(SlimHttpResponse), Object(SlimApp))
#10 /opt/myanime/api/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(73): call_user_func(Object(SlimDeferredCallable), Object(SlimHttpRequest), Object(SlimHttpResponse), Object(SlimApp))
#11 /opt/myanime/api/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(122): SlimApp->Slim{closure}(Object(SlimHttpRequest), Object(SlimHttpResponse))
#12 /opt/myanime/api/vendor/slim/slim/Slim/App.php(370): SlimApp->callMiddlewareStack(Object(SlimHttpRequest), Object(SlimHttpResponse))
#13 /opt/myanime/api/vendor/slim/slim/Slim/App.php(295): SlimApp->process(Object(SlimHttpRequest), Object(SlimHttpResponse))
#14 /opt/myanime/api/public/index.php(35): SlimApp->run()
#15 {main}
My routes for new endpoint:
$app->get('/user/notification', 'UserController:getNotification');
My class:
class UserController{
public function __construct($container)
{
// make the container available in the class
$this->container = $container;
}
public function getNotification($request, $response, $args){
//my code here
}
}
my dependencies.php
:
use AppControllersUserController;
$container = $app->getContainer();
$container['UserController'] = function ($c) {
return new UserController($c);
};
my composer.json
{
"name": "slim/slim-skeleton",
"autoload": {
"psr-4": {
"App": "src/"
}
}
}
tried to composer dump-autoload
but that did not work.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…