I created my website around composer. In my localhost (use xampp) it works perfectly, but when I upload it to my hosting (with dependencies etc that composer creates) throws me an error that I can not solve.
Depending on the error, it does not find the controller, but that controller is created and in the correct folder.
Try installing composer in the hosting through an SSH that facilitates the same panel, but always tells me that does not exist / finds most of the commands that are needed for the installation (I suppose they will be layered), either curl (a tutorial required it) or almost any other. I have followed the tutorials of the composer documentation and I have not achieved any results either
Try to do from my location; Composer dumpautoload, and upload it to the host to see if it solved something, but I kept throwing the same error.
Error thrown:
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;
}
}
}