I’m writing my own little MVC and I got a question… I’m passing $_SERVER['REQUEST_URI'] to the Router class which returns me controller, it’s action and array of GET parameters.
(For example Router said that I should call App_Controller->index()).
So, I should create instance of App_Controller and call index() method. So, I’m doing something like $controller = new $controller_name etc. But what if controller is not found by spl_autoload_register() (I’m using autoload).
How can I generate Exception about the fact that controller is not found? Or maybe I’m doing something wrong?
Thank you.
You could check it using
class_existswhich has a $autoload parameter (set to true as default, and therefore tries to autoload the class).