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

In CI3 I usually use something like:
PHP Code:
$ci =& get_instance();

How to do it in CI4?

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(); 

[font=Lato, proxima-nova,]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:[/font]
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )

Theme © iAndrew 2016 - Forum software by © MyBB