![]() |
Cannot access method in Controller!? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28) +--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30) +--- Thread: Cannot access method in Controller!? (/showthread.php?tid=77434) |
Cannot access method in Controller!? - blaasvaer - 09-01-2020 I've set this in my App\Config\App.php: public $baseURL = 'http://localhost/my_project/'; I've added this in my Home Controller: Code: <?php namespace App\Controllers; I've copied the index.php and .htaccess from the public directory into the root and modified the path accordingly: Code: $pathsPath = realpath(FCPATH . 'app/Config/Paths.php'); // removed the preceding dots ../ I've also added the view test.php in the Views directory ... Now, why can't I access the test method in the Home controller by doing this: Code: http://localhost/my_project/test ? Well. Maybe because I didn't add the Controller name before the method OR didn't set it specifically in the Routes.php ... I just 'thought' that, as the default controller is set, it would 'automagically' use that if left out ... but that would probably have been a bit weird ... so. RE: Cannot access method in Controller!? - blaasvaer - 09-01-2020 OK, so I received an e-mail that someone had replied to my post: Code: blaasvaer, But I don't see the reply in the thread!? RE: Cannot access method in Controller!? - paulbalandan - 09-01-2020 In the $pathsPath, change FCPATH to ROOTPATH RE: Cannot access method in Controller!? - blaasvaer - 09-01-2020 To prevent other answers I'll throw my own quick replies as a 'regular' reply. Well. Maybe because I didn't add the Controller name before the method OR didn't set it specifically in the Routes.php ... I just 'thought' that, as the default controller is set, it would 'automagically' use that if left out ... but that would probably have been a bit weird ... so. RE: Cannot access method in Controller!? - jreklund - 09-02-2020 That's why I deleted my reply, as I noticed you had already found out why. xD RE: Cannot access method in Controller!? - blaasvaer - 09-02-2020 (09-02-2020, 12:42 AM)jreklund Wrote: That's why I deleted my reply, as I noticed you had already found out why. xD Well, I ‘guess’ the system failed to notify me about the deletion then ... which I think would be the proper respond from a system like this ... but maybe that’s just me. Thanks anyway. RE: Cannot access method in Controller!? - look - 12-04-2022 Why the learn/test curve in ci4 is so high?.... simple things, just starting - and already i'm in forums QA. out of the box - Index method works in default controller. why not other methods? how to call other methods? any call result with : Cannot access the default controller "Home" with the controller name URI path. can't be that there is no simple answer to it. RE: Cannot access method in Controller!? - kenjis - 12-05-2022 You need to define all routes you want. See https://codeigniter4.github.io/CodeIgniter4/incoming/routing.html#setting-routing-rules |