Instead of calling $this->load->library() and $this->load->script() in each controller, you can autoload them so they're always available to every controller by default.
Edit your autoload configuration file:
/myapp/configs/config_autoload.php
$config['libraries'] = ['mylib', 'myotherlib'];
If you want to alias a library, use an array with two values: the plugin name and the alias:
$config['libraries'] = [
['mylib', 'myalias'],
['myotherlib', 'otheralias']
];
$config['scripts'] = ['myhelpers', 'myscripts'];
Script plugins are included globally and their functions are available across all controllers and views.
$config['models'] = ['mymodel', 'monewmodel'];
You can also autoload models with aliases and specify a connection pool:
$config['models'] = [
['mymodel', 'mymodelalias', 'mypool'],
['monewmodel', 'mynewmodelalias', 'mynewpool']
];
To use aliased models and libraries, be sure to declare their properties in your controller. The best way is to extend your base controller and define all the necessary aliases there.
Example:
class My_Controller extends NanoMVC_Controller {
public $mymodelalias;
public $mynewmodelalias;
public $myalias;
public $otheralias;
// Add your common controller logic here
}
Then simply extend My_Controller in your controllers instead of NanoMVC_Controller. For instructions on extending controllers, see the Extending NanoMVC Classes documentation.