NanoMVC allows you to easily extend core classes like NanoMVC_Controller, NanoMVC_Model, or NanoMVC_View to add your own logic and base functionality.
Create your custom controller base class inside the /myapp/plugins/ directory:
// File: /myapp/plugins/my_controller.php
class My_Controller extends NanoMVC_Controller {
// Add your common controller logic here
}
Now in your controllers, extend My_Controller instead of NanoMVC_Controller:
// File: /myapp/controllers/hello.php
class Hello_Controller extends My_Controller {
function index() {
$this->view->display('hello_view');
}
}
Note: You do not need to manually include your custom base class. NanoMVC will autoload it automatically if it is placed in the plugins directory and named as classname.php.
The same process works for NanoMVC_Model and NanoMVC_View:
/myapp/plugins/my_model.php — class My_Model extends NanoMVC_Model/myapp/plugins/my_view.php — class My_View extends NanoMVC_ViewYou can then use your extended versions in your application wherever needed.