Welcome Guest, Not a member yet? Register   Sign In
helper
#1

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!
Reply
#2

It would help if you tell us what it is you want to do not how you use to do it.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

(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
Reply
#4

(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.
Reply
#5

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.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#6

(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!!
Reply
#7

(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
Reply




Theme © iAndrew 2016 - Forum software by © MyBB