My php system is working on Windows but is giving error on UBUNTU

Asked

Viewed 84 times

3

I’m using auto-load PSR-4. The error is as follows:

Fatal error: Uncaught Error: Class 'App Models Bll Professor' not found in /var/www/html/unaprojetos/App/Controllers/Professor.php:12 Stack trace: #0 /var/www/html/unaprojetos/App/Routes.php(81): App Controllers Professor->index() #1 [Internal Function]: App Routes->App{closure}(Array, 'teacher') #2 /var/www/html/unaprojetos/App/Routes.php(83): array_walk(Array, Object(Closure)) #3 /var/www/html/unaprojetos/App/Routes.php(19): App Routes->run('/teacher') #4 /var/www/html/unaprojetos/public/index.php(8): App Routes->__Construct() #5 {main} thrown in /var/www/html/unaprojetos/App/Controllers/Professor.php on line 12

So is my code:

<?php


namespace App\Controllers;

class Professor extends Cadastrousuario{
    /*
     * O MÉTODO INDEX É PUBLICO, PORTANTO O SISTEMA NÃO FARÁ VERIFICAÇÃO DE LOGIN
     * PARA PERMITIR QUE PESSOAS SEM CADASTRO POSSAM ACESSAR ESSA PAGINA E SE CADASTRAR
     */
    public function index($msg=""){
        $view = new \App\Views\Cadastrousuario\Professor();
        $model = new \App\Models\Bll\Professor();
        $view->render($model->consultar(), $msg, "novo");
    }

    public function consultar($msg=""){
        /*
         * VERIFICA SE HÁ UMA SESSION EM ANDAMENTO, SE NÃO CRIA UMA NOVA
         * EM SEGUIDA VERIFICA SE O USUARIO ESTÁ LOGADO, SE NÃO O REDIRECIONA A PAGINA DE LOGIN
         */
        if (!isset($_SESSION)) {
            session_start();
        }
        if (isset($_SESSION['logado']) == true){
            $view = new \App\Views\Cadastrousuario\Professor();
            $model = new \App\Models\Bll\Professor();
            $view->render($model->consulta(), $msg, "editar"); 
        }
        else{
            header("Location: http://$_SERVER[HTTP_HOST]/login");
        }
    }
  • This class you put up has nothing to do with the error, edit your question and put the file code App/Controllers/Professor.php

  • Updated. The error is the same for both classes.

1 answer

5


Is a problem of case sensitivity. Unlike Windows, Ubuntu will not accept paths where the first letter is uppercase as if all letters were lowercase and vice versa. I noticed that your classes are using lower case names, probably the name of the PHP file should be capitalized.

public function consultar($msg=""){
    /*
     * VERIFICA SE HÁ UMA SESSION EM ANDAMENTO, SE NÃO CRIA UMA NOVA
     * EM SEGUIDA VERIFICA SE O USUARIO ESTÁ LOGADO, SE NÃO O REDIRECIONA A PAGINA DE LOGIN
     */
    if (!isset($_SESSION)) {
        session_start();
    }
    if (isset($_SESSION['logado']) == true){
        $view = new \App\Views\Cadastrousuario\Professor();
        $model = new \App\Models\Bll\Professor();
        $view->render($model->consulta(), $msg, "editar"); 
    }
    else{
        header("Location: http://$_SERVER[HTTP_HOST]/login");
    }
}

Check the classes used in this example.

  • But I checked here and the classes are with the first letter capitalized as well as the call in the objects.

  • Nice!!! It was right the problem is Case Sensitive, however the error was in the folders BLL and DAL, which in the construction of the object was only the first letter in capital.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.