CodeIgniter Forums
helper - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: helper (/showthread.php?tid=78117)



helper - Llui7 - 12-03-2020

Hello
I am new to codeginiter4

I cannot see the controller that I am currently in from a helper.

In codeigniter3 I used:
$ CI = & get_instance ();
$ CI-> router-> class;
$ CI-> router-> method;

I don't know how to do it in codeigniter4

Thanks!


RE: helper - InsiteFX - 12-03-2020

It would help if you tell us what it is you want to do not how you use to do it.


RE: helper - Llui7 - 12-03-2020

(12-03-2020, 04:18 AM)InsiteFX Wrote: It would help if you tell us what it is you want to do not how you use to do it.

From a helper:  show the current controller and the function of the page a user is visiting


RE: helper - sammyskills - 12-03-2020

(12-03-2020, 02:56 AM)Llui7 Wrote: Hello
I am new to codeginiter4

I cannot see the controller that I am currently in from a helper.

In codeigniter3 I used:
$ CI = & get_instance ();
$ CI-> router-> class;
$ CI-> router-> method;

I don't know how to do it in codeigniter4

Thanks!

This is easier to do in CI4. You just have to learn about namespaces. See this forum thread for more details.


RE: helper - InsiteFX - 12-03-2020

This is easy in CodeIgniter 4

PHP Code:
$router service('router'); 

$controller $router->controllerName();
$method     $router->methodName();

$logger service('logger');
$routes service('routes'); 

All most all CodeIgniter 4 Core Classes are invoked by a service.


RE: helper - Llui7 - 12-04-2020

(12-03-2020, 05:06 PM)InsiteFX Wrote: This is easy in CodeIgniter 4

PHP Code:
$router service('router'); 

$controller $router->controllerName();
$method     $router->methodName();

$logger service('logger');
$routes service('routes'); 

All most all CodeIgniter 4 Core Classes are invoked by a service.

Wow it's very simple

thank you InsiteFX!!


RE: helper - Llui7 - 12-04-2020

(12-03-2020, 06:51 AM)sammyskills Wrote:
(12-03-2020, 02:56 AM)Llui7 Wrote: Hello
I am new to codeginiter4

I cannot see the controller that I am currently in from a helper.

In codeigniter3 I used:
$ CI = & get_instance ();
$ CI-> router-> class;
$ CI-> router-> method;

I don't know how to do it in codeigniter4

Thanks!

This is easier to do in CI4. You just have to learn about namespaces. See this forum thread for more details.


Thanks for the information!! i will read about namespaces