There may be situations where you need to access the current application instance outside the controller — for example, inside a library, model, or plugin — in order to call controller methods or interact with views.
You can retrieve the instance at any time using:
$nmvc = nmvc::instance();
Once you have the instance, you can use it to work with views, configuration, and other controller-related functionality:
$myvars = [];
$myvars['foo'] = 'bar';
$myvars['baz'] = 'gaz';
$output = $nmvc->controller->view->fetch('some_view', $myvars);
The nmvc::instance() object exposes several helpful properties:
$nmvc->controller — the current controller object$nmvc->action — the name of the controller method currently being executed$nmvc->url_segments — an array of URL segments following the controller and action$nmvc->config — the loaded application configuration arrayThese allow you to interact with the runtime context of the application, even when you're outside the main controller scope.