I am new to mvc,I am currently building my on mvc and m finding some difficulties in building it.I am getting this error:
Fatal error: Uncaught Error: Class 'userscontroller' not found in C:\xampp\htdocs\mvc1\app\core\app.php:20 Stack trace: #0 C:\xampp\htdocs\mvc1\public\index.php(4): app->__construct() #1 {main} thrown in C:\xampp\htdocs\mvc1\app\core\app.php on line 20
If you need anyother code of mvc included in my directories,you are free ask :)
Please help me to resolve the error I have made in the following code:
app.php Click here to see the image containing my directory files
<?php
class app{
protected $controller ='userscontroller';
protected $method ='users';
protected $params =[];
function __construct()
{
$url =$this->url();
if(file_exists('../app/controllers/'.$url[0].'.php')){
$this->controller = $url[0];
unset($url[0]);
}
require_once '../app/controllers/'.$this->controller .'.php';
$this->controller = new $this->controller;
if(isset($url[1])){
if (method_exists($this->controller,$url[1])){
$this->method = $url[1];
unset($url[1]);
}
}
$this->params = $url ? array_values($url) :[];
call_user_func_array([$this->controller,$this->method],$this->params);
}
function url(){
if(isset($_GET['url'])){
return explode('/',filter_var(rtrim($_GET['url',' /'),FILTER_SANITIZE_URL));
}
}
}
?>
[1]: https://i.stack.imgur.com/TEPhW.png