Uncaught Error: Class not found - Slim Framework

0

I'm getting this error:

Fatal error: Uncaught Error: Class 'CrudUser' not found in /home/doupenglish/www/api/index.php:27 Stack trace: #0 [internal function]: Closure->{closure}(Object(Slim\Http\Request), Object(Slim\Http\Response), Array) #1 /home/doupenglish/www/api/vendor/slim/slim/Slim/Handlers/Strategies/RequestResponse.php(41): call_user_func(Object(Closure), Object(Slim\Http\Request), Object(Slim\Http\Response), Array) #2 /home/doupenglish/www/api/vendor/slim/slim/Slim/Route.php(325): Slim\Handlers\Strategies\RequestResponse->__invoke(Object(Closure), Object(Slim\Http\Request), Object(Slim\Http\Response), Array) #3 /home/doupenglish/www/api/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(114): Slim\Route->__invoke(Object(Slim\Http\Request), Object(Slim\Http\Response)) #4 /home/doupenglish/www/api/vendor/slim/slim/Slim/Route.php(297): Slim\Route->callMiddlewareStack(Object(Slim\Http\Request), Object(Slim\Http\Response)) #5 /home/doupenglish/www/api/vendor/slim/slim/Slim/App.php(433): Slim\Route->run(Object(Slim\Http\Request), Object(Slim\Ht in /home/doupenglish/www/api/index.php on line 27

When I try to do a get using slimframework like this:

$app->get('/usuario',function(Request $request,Response $response){
    $usermail = $request->getHeader('PHP_AUTH_USER');
    $senha = $request->getHeader('PHP_AUTH_PW'); 

    $sql = new Sql();    
    $user = new CrudUser();
    $autenticado = $user->login($usermail,$senha);
    if ($autenticado) {
        $resultado = $sql->select("SELECT * FROM tb_alunos WHERE email = :EMAIL",array(
            ":EMAIL"=>$usermail
        ));
        $response = json_encode($resultados);
    }else{
        $response->withStatus(401);
    }
    return $response;
});

I'm doing auto load with these 2 files, it was working

    require 'vendor/autoload.php';
require 'config.php';

Config.php file:

    <?php
spl_autoload_register(function($class_name){
    $filename = "class".DIRECTORY_SEPARATOR.$class_name.".php";
    if(file_exists(($filename))){
        require_once($filename);
    }
});
?>
    
asked by anonymous 19.12.2017 / 14:38

0 answers