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

(11-09-2016, 08:12 PM)kilishan Wrote: 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.

I thing:


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

    public function __construct(...$params)
    {
        $this->helpers[] = 'url';
        parent::__construct(...$params);
    }
}
Reply


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



Theme © iAndrew 2016 - Forum software by © MyBB