problem with custom controller constructor |
(06-22-2022, 12:54 PM)groovebird Wrote:(05-29-2021, 12:25 PM)includebeer Wrote: Don't use a constructor. Override initController(), don't forget to call parent::initController(), and then do what you need to do. No, it's not the CI4 way to use a constructor. The problem is you're trying to access objects that are not yet initialized. The request object is available after initController() has run. The constructor is too early in the cycle. Look at the code in the BaseController for an example. You need to override the initController method, call its parent, then do what you want after that. PHP Code: /**
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
/*** NO support in private message - Use the forum! ***/ |
Welcome Guest, Not a member yet? Register Sign In |