Welcome Guest, Not a member yet? Register   Sign In
how to load the helper(url) automatically in CI4?
#3

Simplest method currently is to have a BaseController that loads it up. It can be done something like:

Code:
class BaseController extends CodeIgniter\Controller
{
   protected $helpers = [];  // this is already part of the Controller class

   public function __construct(...$params)
   {
       parent::__construct(...$params);

       $this->helpers = array_merge($this->helpers, ['url', 'foo']);
   }
}

This is a little more work up front, but most projects will see you using a base controller or two anyway.
Reply


Messages In This Thread
RE: how to load the helper(url) automatically in CI4? - by kilishan - 11-09-2016, 08:12 PM



Theme © iAndrew 2016 - Forum software by © MyBB