Problem when passing my api rest from a localhost to a hosting

0

My problem is the following I want to upload my Api Rest for which I used Framework Slim 3 to a web hosting (hostinger). The problem is that in my localhost worked perfectly but now when I want to mount it in a hosting it returns the following error Fatal error: Class 'Slim\App' not found in /home/u798910997/public_html/Api/app/route/usuario.php on line 15

app / config / db.php

<?php

class db {

    private $dbhost = "mysql.hostinger.com.ar";
    private $dbuser = "(mi usuario)";
    private $dbpass = "(mi pass)";
    private $dbname = "(mi bd)";

    public function connect(){
        $mysql_connect_str = "mysql:host=$this->dbhost;dbname=$this->dbname";
        $dbConnection = new PDO($mysql_connect_str, $this->dbuser, $this->dbpass);
        $dbConnection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        return $dbConnection;
    }
}

app / route / user.php

<?php

use \Psr\Http\Message\ServerRequestInterface as Request;
use \Psr\Http\Message\ResponseInterface as Response;

$app = new \Slim\App;   

$app->group('/usuario/', function () {


$this-> get('', function(Request $request, Response $response){

    $sql = "select * from usuario";

    try{
        $db = new db();

        $db = $db->connect();

        $stmt = $db->query($sql);
        $usuario = $stmt->fetchAll(PDO::FETCH_OBJ);
        $db = null;
        echo json_encode($usuario);

    } catch(PDOException $e){
        echo '{"error": {"text": '.$e->getMessage(). '}';
    }
});

app / public / .htaccess

   RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [QSA,L]

app / public / index.php

    <?php
use \Psr\Http\Message\ServerRequestInterface as Request;
use \Psr\Http\Message\ResponseInterface as Response;

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

$configuration = [
    'settings' => [
        'displayErrorDetails' => true,
        "outputBuffering" => false,
        'addContentLengthHeader' => false,
    ],
];


$app = new \Slim\App($configuration);
require '../app/route/usuario.php';

$app->run();

Directory structure on localhost and server

composer.json

{
    "require": {
        "slim/slim": "^3.0"
    }
}
    
asked by Germanccho 18.04.2018 в 17:15
source

0 answers