Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Codeigniter: call a controller from another codeigniter file

I have this two file path:

    1: /api/math/application/controllers/test.php 
    2: /learn/mathtek/application/controllers/Auth.php

I need to call the controller from path2(Auth) inside the controller of path1(test). Is this possible? if yes how?

Ive tried to used the redirect() function but didnt work. Also i tried this:

require_once('/learn/mathtek/application/controllers/Auth.php');
            $aObj = new a();  //create object 
            $aObj->custom_a(); //call function

but it still didnt work...help please ... newbie in codeigniter here

like image 855
Caloy Avatar asked Jan 29 '26 10:01

Caloy


1 Answers

Thanks guys for the help. I ended up doing a direct post of the path using redirect function to make it work.

1: /api/math/application/controllers/test.php - codeigniter1
2: /learn/mathtek/application/controllers/Auth.php - codeigniter2

Examples: If i want to call path(2) from path(1).

redirect('http://localhost/learn/mathtek/auth/signin'); --'signin' is a function inside 'auth' controller

thats the code inside the 'test' controller. This works in codeigniter even if its from different path of controller.

However this doesnt work for UNITY(WEBGL). Thats why i ended doing an echo and returning it back.

like image 120
Caloy Avatar answered Jan 30 '26 22:01

Caloy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!