Foros del Web » Programando para Internet » PHP » Frameworks y PHP orientado a objetos »

MVC Fatal error: Uncaught Error: Call to undefined method Exception::getMenssage()

Estas en el tema de MVC Fatal error: Uncaught Error: Call to undefined method Exception::getMenssage() en el foro de Frameworks y PHP orientado a objetos en Foros del Web. 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: ...
  #1 (permalink)  
Antiguo 19/12/2016, 15:01
 
Fecha de Ingreso: enero-2008
Mensajes: 580
Antigüedad: 16 años, 3 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";
        }
    }
?>
  #2 (permalink)  
Antiguo 21/12/2016, 07:55
 
Fecha de Ingreso: diciembre-2011
Ubicación: Crespo - Entre Rios
Mensajes: 155
Antigüedad: 12 años, 4 meses
Puntos: 25
Respuesta: MVC Fatal error: Uncaught Error: Call to undefined method Exception::getMe

Tenes una n demás en la llamada al método.

En index.php, tenes casi al final $e->getMensagge() y debería ser $e-getMessage()

Etiquetas: call, fatal, method, mvc, undefined
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 16:52.