![]() |
Hi All,
I am currently working on a project, where I am keeping all my code in a module. So my structure is as below: Code: -app Now everything else from Modules (Routes, Controllers, Views) is working fine as I have provided namespace in Autoload.php, but Helpers and Constants are not working as they are not classes. In app > Config > autoload.php, I tried to add files as well with correct path, but it is still not working. Code: public $files = [ I can make it work if I make them classes, but before I do that way, I want to check how to make it work without making classes. I read CI guide at https://codeigniter4.github.io/userguide...ml#helpers , where it is written that "Helpers will be automatically discovered within defined namespaces when using the Code: helper() But it is not working. I tried that way as well in the Controller. Code: helper('MyModule\Admin\Helpers\functions'); Any idea from anyone?
What version of CodeIgniter are you running?
You should not be using a slash \ at the begining of the path. What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
PHP Code: public $files = [ Or update CI and use: Code: public $helpers = [];
Thanks everyone! It is now working with below both options:
ROOTPATH . 'mymodule/admin/Helpers/*.php', and '../mymodule/admin/Helpers/*.php' For some reason I believe that I used ROOTPATH earlier but it was not working. May be I used /mymodule at that time (can't remember). |
Welcome Guest, Not a member yet? Register Sign In |