NanoMVC

Getting an Instance

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);

Available Properties

The nmvc::instance() object exposes several helpful properties:

These allow you to interact with the runtime context of the application, even when you're outside the main controller scope.

← to Autoloading Plugins to Integrating a Template Engine →

← Back to Documentation