Sysabm.cf

sysabm.cf

sysabm.cf

Error Message

Fatal error : Uncaught Error: Class ‘controller’ not found in /home/vol6_8/epizy.com/epiz_24477343/htdocs/controllers/homeController.php:2 Stack trace: #0 /home/vol6_8/epizy.com/epiz_24477343/htdocs/index.php(7): require_once() #1 [internal function]: {closure}(‘homeController’) #2 /home/vol6_8/epizy.com/epiz_24477343/htdocs/core/Core.php(36): spl_autoload_call(‘homeController’) #3 /home/vol6_8/epizy.com/epiz_24477343/htdocs/index.php(16): Core->run() #4 {main} thrown in /home/vol6_8/epizy.com/epiz_24477343/htdocs/controllers/homeController.php on line 2

Other Information

My .htaccess:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule ^(.*)$ http://sysabm.cf/index.php?url=$1 [QSA,L]
RewriteRule ^(.+)$ /index.php?url=$1 [QSA,L]

My index.php:

<?php
session_start();
require 'config.php';

spl_autoload_register(function ($class){
    if(file_exists('controllers/'.$class.'.php')) {
            require_once 'controllers/'.$class.'.php';
    } elseif(file_exists('models/'.$class.'.php')) {
            require_once 'models/'.$class.'.php';
    } elseif(file_exists('core/'.$class.'.php')) {
            require_once 'core/'.$class.'.php';
    }
});

$core = new Core();
$core->run();
?>

My controller:

<?php
class homeController extends controller {

	private $user;

    public function __construct() {
        parent::__construct();
    }

    public function index() {
        
        $dados = array();
        
        $alunos = new Alunos();
        $func = new Funcionarios();

        $a = $alunos->totalAluno();
        $f = $func->totalFunc();
        $niverAlunos = $alunos->niverAlunos();

        $dados['talunos'] = $a;
        $dados['tfunc'] = $f;
        $dados['niverAlunos'] = $niverAlunos;

        $this->loadTemplate('home', $dados);
    }

}

help please!

I think your issue could be with your autoloader. Most likely what is happening is that the homeController class file is being loaded BEFORE the controller file therefore meaning that the homeController class can’t detect the controller.

tl;dr: most likely your autoloader is causing this

3 Likes

The autoloader and homeController look fine to me. But is the file that contains the base class controller also present and loaded?

Taking a quick look in your account, I see there is a file Controller.php, but not controller.php.

So please note that our servers, like almost all servers, run on Linux and that file and directory names on Linux are case sensitive (unlike on Windows and MacOS).

4 Likes

The class name is controller and the file is Controller.php

<?php
 class controller {

 	protected $db;
 	protected $lang;

 	public function __construct() {
 		global $config;
 		$this->lang = new Language();

 	}
 	
 	public function loadView($viewName, $viewData = array()) {
 		extract($viewData);
 		include 'views/'.$viewName.'.php';
 	}

 	public function loadTemplate($viewName, $viewData = array()) {
 		include 'views/template.php';
 	}

 	public function loadViewInTemplate($viewName, $viewData) {
 		extract($viewData);
 		include 'views/'.$viewName.'.php';
 	}

 }

But I will change the name of the files to see

Exactly. But your autoloader looks for controller.php, not Controller.php. And while on your local XAMPP stack those files would be the same (because Windows), on most servers, including ours, they are not.

1 Like

I adjusted the name of the Class and it worked, thank you!
Now it is showing ERR_TOO_MANY_REDIRECTS, but I still can’t see the error yet.

Is http://sysabm.cf/login a valid link?

I don’t know, but even the homepage gives the error.

Well homepage is redirecting to

Some .htaccess issue I gather

I’m not sure it’s a .htaccess issue. It looks more like an issue with the authentication setup. Remember: you normally want to enforce authentication for every page EXCEPT for login pages and the like.

I don’t validate authentication on the login screen, I’m calling the view login and it seems to give an error, but I don’t know why, if I take it out and leave it to open the home it opens normal

I couldn’t see any problems with .htaccess

Well now your account is suspended for something, can you check the client area and tell us what it was suspended for?


Thanks!

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.