I created my website around composer. In my localhost (using xampp) it works perfectly, but when I upload it to my hosting (with the vendor and other files that composer creates) I get the following error that I can not solve.
According to the error, it does not find the controller, but that controller is created and in the place it should be.
Error
Fatal error: Uncaught ReflectionException: Class App \ Controllers \ IndexController does not exist in /usr/home/defuse.es/web/defuse/vendor/phroute/phroute/src/Phroute/RouteCollector.php:315 Stack trace: # 0 /usr/home/defuse.es/web/defuse/vendor/phroute/phroute/src/Phroute/RouteCollector.php(315): ReflectionClass-> construct ('App \ Controllers ...') # 1 / usr / home / defuse.es / web / defuse / public / index.php (52): Phroute \ Phroute \ RouteCollector-> controller ('/', 'App \ Controllers ...') # 2 {main} thrown in /usr/home/defuse.es/web/defuse/vendor/phroute/phroute/src/Phroute/RouteCollector.php on line 315 '
Code
public function controller($route, $classname, array $filters = [])
{
$reflection = new ReflectionClass($classname); /*Marca el error en esta linea*/
$validMethods = $this->getValidMethods();
$sep = $route === '/' ? '' : '/';
foreach($reflection->getMethods(ReflectionMethod::IS_PUBLIC) as $method)
{
foreach($validMethods as $valid)
{
if(stripos($method->name, $valid) === 0)
{
$methodName = $this->camelCaseToDashed(substr($method->name, strlen($valid)));
$params = $this->buildControllerParameters($method);
if($methodName === self::DEFAULT_CONTROLLER_ROUTE)
{
$this->addRoute($valid, $route . $params, [$classname, $method->name], $filters);
}
$this->addRoute($valid, $route . $sep . $methodName . $params, [$classname, $method->name], $filters);
break;
}
}
}