Slim framework error and cpainel JWT authentication


I have the following problem: Slim works without problems with jwt authentication. When I pass the files to my server's cpainel, slim middleware pales because the scripts are in the provider's folder outside of public_html. They even informed me that this can cause problems, but there is no solution. I can't place the provider's public_html folder because it can't find the path of the route.

My index.php

if (PHP_SAPI == & # 39; cli-server & # 39;) {
// To help the integrated PHP development server, check if the request was really for
// something that should probably be served as a static file
$ url = parse_url ($ _ SERVER (& # 39; REQUEST_URI & # 39;));
$ file = Direct . $ url (& # 39; route & # 39;);
if (is_file ($ file)) {
returns false;

}

}

demand Direct . & # 39; /../ autoload.php & # 39 ;;

session_start ();

// Instance the application
$ settings = require Direct . & # 39; /../ src / settings.php & # 39 ;;
$ app = new Slim App ($ settings);

// Configure dependencies
demand Direct . & # 39; /../ src / dependencies.php & # 39 ;;

// Register middleware
demand Direct . & # 39; /../ src / middleware.php & # 39 ;;

// Register routes
demand Direct . & # 39; /../ src / routes.php & # 39 ;;

// Run application
$ app-> run ();

My Middleware.php

// for example: $ app-> add (new Slim Csrf Guard);

$ app-> add (new Tuupola Middleware JwtAuthentication ((
"path" => "/ api", / * or ("/ api", "/ admin") * /
"attribute" => "decoded_token_data",
"secret" => "supersecretkeyyoushmitmitmitmittogithub",
"algorithm" => ("HS256"),
"error" => function ($ answer, $ arguments) {
$ data ("status") = "error";
$ data ("message") = $ arguments ("message");
return $ answer
-> withHeader ("Content-Type", "application / json")
-> write (json_encode ($ data, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT));
}
)));

These codes work in Xampp. The problem is in cpainel

My test routes

$app->post('/login', function (Request $request, Response $response, array $args) {

$input = $request->getParsedBody();
$sql = "SELECT * FROM tab_usuario WHERE cadastro_usuario= :cadastro_usuario";
$sth = $this->db->prepare($sql);
$sth->bindParam("cadastro_usuario", $input('cadastro_usuario'));
$sth->execute();
$user = $sth->fetchObject();

// verify email address.
if(!$user) {
    return $this->response->withJson(('error' => true, 'message' => 'These credentials do not match our records.'));  
}

// verify password.
if (!password_verify($input('senha_usuario'),$user->senha_usuario)) {
    return $this->response->withJson(('error' => true, 'message' => 'These credentials do not match our records.'));  
}

$settings = $this->get('settings'); // get settings array.

$token = JWT::encode(('cod_usuario' => $user->cod_usuario, 'cadastro_usuario' => $user->cadastro_usuario), $settings('jwt')('secret'), "HS256");

return $this->response->withJson(('token' => $token));

});

$ app-> group (& # 39; / api & # 39 ;, function () use ($ app) {

$app->get('/user',function(Request $request, Response $response, array $args) {
    print_r($request->getAttribute('decoded_token_data'));       


});

});

$ app-> get (& # 39; / allproducts & # 39 ;, function ($ request, $ response, $ args) {
$ sth = $ this-> db-> prepare ("SELECT * FROM products");
$ sth-> execute ();
$ all = $ sth-> fetchAll ();
returns $ this-> response-> withJson ($ all);
});

I would like to know the options I have if it is not possible to use JWT with Slim. I need to protect the routes.