Ver Mensaje Individual
  #1 (permalink)  
Antiguo 19/12/2016, 15:01
quico5
 
Fecha de Ingreso: enero-2008
Mensajes: 581
Antigüedad: 16 años, 10 meses
Puntos: 9
MVC Fatal error: Uncaught Error: Call to undefined method Exception::getMenssage()

http://localhost/mvc/public/casa
Cita:
Fatal error: Uncaught Error: Call to undefined method Exception::getMenssage() in C:\xampp\htdocs\mvc\public\index.php:15 Stack trace: #0 {main} thrown in C:\xampp\htdocs\mvc\public\index.php on line 15
.htaccess
Código:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.+) index.php?url=$1 [QSA,L]
index.php
Código PHP:
<?php
    chdir
(dirname(__DIR__));
    
define("SYS_PATH","lib/");
    
define("APP_PATH","app/");
    require 
SYS_PATH."Router.php";
    require 
APP_PATH."http/routes.php";
    try {
        
$action Router::getAction($_GET["url"]);
        
$controllerName $action["controller"];
        
$method $action["method"];
        require 
APP_PATH."controllers/".$controllerName.".php";
        
$controller = new $controllerName();
        
$controller->$method();
    } catch (
Exception $e) {
        echo 
$e->getMenssage();
    }
?>
Router.php
Código PHP:
<?php
    
class Router{
        private static 
$routes = [];
        private function 
__construct(){}
        public static function 
add($route,$controller,$method){
            static::
$routes[$route] = ["controller" => $controller"method" => $method];
        }
        public static function 
getAction($route){
            if(
array_key_exists($route, static::$routes)){
                return static::
$routes[$route];
            }else{
                throw new 
Exception("The route '$route' was not found");
            }
        }
    }
?>
routes.php
Código PHP:
<?php
    Router
::add("home","MainController","index");
    
Router::add("about","MainController","about");
?>
MainController.php
Código PHP:
<?php
    
class MainController{
        public function 
index(){
            echo 
"Hola desde el index";
        }
        public function 
about(){
            echo 
"Hola desde el about";
        }
    }
?>