What could be causing this error? Thank you
Fatal error: Uncaught RuntimeException: Callable App\Controllers\CitasController::getAll() does not exist in C:\xampp\htdocs\servidorapi\vendor\slim\slim\Slim\CallableResolver.php:152 Stack trace: #0 C:\xampp\htdocs\servidorapi\vendor\slim\slim\Slim\CallableResolver.php(103): Slim\CallableResolver->resolveSlimNotation(‘App\Controllers…’) #1 C:\xampp\htdocs\servidorapi\vendor\slim\slim\Slim\CallableResolver.php(72): Slim\CallableResolver->resolveByPredicate(‘App\Controllers…’, Array, ‘handle’) #2 C:\xampp\htdocs\servidorapi\vendor\slim\slim\Slim\Routing\Route.php(366): Slim\CallableResolver->resolveRoute(‘App\Controllers…’) #3 C:\xampp\htdocs\servidorapi\vendor\slim\slim\Slim\MiddlewareDispatcher.php(81): Slim\Routing\Route->handle(Object(Slim\Psr7\Request)) #4 C:\xampp\htdocs\servidorapi\vendor\slim\slim\Slim\MiddlewareDispatcher.php(81): Slim\MiddlewareDispatcher->handle(Object(Slim\Psr7\Request)) #5 C:\xampp\htdocs\servidorapi\vendor\slim\slim\Slim\Routing\Route.php(341): Slim\MiddlewareDispatcher->handle(Objec in C:\xampp\htdocs\servidorapi\vendor\slim\slim\Slim\CallableResolver.php on line 152
Annex structure and code that I have made:
In the main .htaccess file:
RewriteEngine on
RewriteBase /servidorapi/public/
RewriteRule ^$ public/ [L]
RewriteRule (.*) public/$1 [L]
In the .htaccess file that is inside public:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [QSA,L]
In the index.php file:
<?php
require __DIR__ . '/../src/App/App.php';
In the app.php file:
<?php
use Slim\Factory\AppFactory;
require __DIR__ . '/../../vendor/autoload.php';
require __DIR__ . '/../../src/config/db.php';
$app = AppFactory::create();
require __DIR__ . '/Routes.php';
$app->run();
in the Routes.php:
<?php
//ayuda a definir las rutas en grupos
use Slim\Routing\RouteCollectorProxy;
//definen grupo de rutas
$app->group('/api',function(RouteCollectorProxy $group){
$group->get('/citas','App\Controllers\CitasController:getAll');
});
In the CitasController.php:
<?php namespace App\Controllers;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
class CitasController{
public function getAll($request,$response,$arg){
$response->getBody()->write("Hello, Word!");
return $response;
}
}
In the composer.json:
{
"require": {
"slim/slim": "4.*",
"slim/psr7": "^1.5",
"php-di/php-di": "^6.3"
},
"autoload":{
"psr-4":{
"App\\" : "src/"
}
}
}