Novice to Ninja book {error} while using XAMPP

Looking at your code, you’re on the CMS-EntryPoint-Namespaces-Router sample

The issue is this line:

$action = !empty($routes[$this->route][$this->method]['action']);

The book never has !empty around this line, and the addition of the empty check is the cause of your problem. empty() will return true or false. So you’re essentially doing $controller->true() and there is no method (and cant be a method) with the value true as a name.

Remove empty so it’s like the book:

$action = $routes[$this->route][$this->method]['action'];

Then var_dump the $action variable to check it contains the relevant value, it should be a string, the name of the method to call in the controller. If it’s not a string (or you get undefined index) then double check the $routes array.

2 Likes