• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how to load the helper(url) automatically in CI4?

#10
(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.

Does it possible to load helper function through config/Autoload.php?
Q&A for Codeigniter
StartBBS--open-source, light weight forum software.
Best VPS:Digital Ocean
Reply


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

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.