Custom controller - request object empty in constructor |
(06-24-2022, 02:56 PM)kenjis Wrote:(06-22-2022, 11:41 AM)groovebird Wrote: This means if i want to use the __construct i have to use \Config\Services::request(). I do not agree with this statement. The initController() method is used because CI doesn't use a service container and can't inject dependencies. In my opinion, the controller should not be dependent on other classes by default, and CodeIgniter\Controller and App\Controllers\BaseController should only add additional functionality/helper methods. Since Services::request() returns the same class instance as set in $this->request, I don't see any bad practice in using a factory service in a constructor. |
Welcome Guest, Not a member yet? Register Sign In |