Welcome Guest, Not a member yet? Register   Sign In
Setting response outside controller
#2

From: CodeIgniter User Guide - Accessing the Request

If you are not within a controller, but still need access to the application’s Request object, you can get a copy of it through the Services class:


PHP Code:
$request = \Config\Services::request(); 

It’s preferable, though, to pass the request in as a dependency if the class is anything other than the controller, where you can save it as a class property:
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply


Messages In This Thread
Setting response outside controller - by maspai - 01-29-2020, 10:26 PM
RE: Setting response outside controller - by InsiteFX - 01-30-2020, 05:38 AM



Theme © iAndrew 2016 - Forum software by © MyBB