Reputation: 73
I have Some Routes On \src\routes.php
$app->get('/coba', 'App\controllers\HomeController:getfromcontroller');
And in myapp/app/controllers/HomeController.php like this
public function getfromcontroller((Request $request, Response $response){
$response->withStatus(200)->write('Hello Motehr!');
}
and if i'am access http://localhost/myapp/public/coba thats errror
Type: RuntimeException Message: Callable App\controllers\HomeController does not exist File: C:\laragon\www\depoapi\vendor\slim\slim\Slim\CallableResolver.php Line: 90
Upvotes: 1
Views: 449
Reputation: 794
They are three things that can happen here.
Are all your URLs being redirected to the index.php in your public folder? in your case
myapp/public.index.php
Make sure you rename your controller folder to Controller and ensure your function is in the controller class.
Try the solution in question 47724219 where you have to use the absolute namespace.
Upvotes: 0
Reputation: 206
Maybe you forgot to call the correct namespace:
$app->get('/coba', ['**YOURAPP**\App\controllers\HomeController', 'getfromcontroller']);
Upvotes: 0