The loader class is the one in charge of loading the models, views, controllers, languages and libraries in Wolff.

Any controller and model that is instantiated already comes with its loader named 'load'.

# Controller

Loading a controller is done in the same way:


If it’s in a subfolder:


This will load the home controller, if no function is specified, the index function of the corresponding controller will be executed.

So you can load a controller function this way:


This will load the home controller and execute its sayHi function instead of index.

# Function

You can load and get the value returned by a controller method using the function method.

$this->load->function('[email protected]');

That will load the getUsers method of the user controller and return its value.

The controller and method name must be separated by a @.

# View

For the views it is the same:


This will load the home.html file inside the app/view folder, if the file with html extension doesn't exists, the loader will try with the php extension (in this case equivalent to app/view/home.php).

Sending data

You can pass data to the view using an array like this:

$data['msg'] = 'Hello world';

$this->load->view('home', $data);

So instead of this way:

<?php echo $data['msg']; ?>

You can use the data in the view this way:

<?php echo $msg; ?>

Or even better, use the template system of Wolff:



The views use by default a cache system, when loading a view a file titled tmp_{fileDirectory}.php will be created in the cache folder if it doesn't exists already, so the view will be loader from that file and any change made to the original file will not be displayed.

You can perfectly refresh the cache deleting the cache folder content.

If you want to force a view to don't use the cache system, you can pass a false value to the loader view function as the third parameter.

$this->load->view('home', $data, false);

This will force that view to don't use the cache system, keep in mind that the loading time could increase due to this.

# Language

When calling the language function of the loader, the data array of the language file is returned. You can load a language this way:


The language file path is determined by the language constant established in the config.php file:

define('LANGUAGE', 'english');

If the language constant is english, it will look for the app/language/english/home.php file. Otherwise, if the language constant is spanish it will look for the app/language/spanish/home.php file.

You can also specify a different language when loading it if you want, like this:

$this->load->language('home', 'spanish');

This will load the spanish language for home no matter the language constant specified in the config.php file.

You can create multiple folders for multiple languages in the app/language folder.

So you can have a home language file like this:

$data['header'] = 'Wolff';

$data['message'] = 'This is ridiculously small';

And in the controller you can get it this way:

$data['language'] = $this->load->language('home');

After that you can load the view in the controller:

$this->load->view('home', $data);

And finally in the view you can do this:

<?php echo $language['header']; ?>

<?php echo $language['message']; ?>