You can create a helper class:
<?php
class Helpers
{
public function sum($argument1, $argument2)
{
return $argument1 + $argument2;
}
}
Then register the class in the di:
$di->set('helpers', function(){
return new Helpers();
});
Then in the views:
<?php echo $this->helpers->sum(1, 2); ?>