CodeIgniter Forums
helper -> call to undefined function - 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 -> call to undefined function (/showthread.php?tid=81856)



helper -> call to undefined function - Kor - 05-10-2022

Greetings.
I have hit a wall here guys.
My app works just fine at localhost, but the most strange thing is happening after I uploaded it to a host.
Here's the scenario:
In my BaseController I have assigned the $helpers var with the helpers to be autoloaded:
Code:
protected $helpers = ['form', 'mylib'];

Inside app\Helpers is the correspondent file: mylib_helper.php
However, my script crashes with the error "call to undefined function", which is a function that exists inside my helper file.
I've tried also to extend my helper, changing its name to form_helper.php, since the form helper is loading just fine, as any native helper in the framework. Only my custom helper doesn't load.
Any thoughts?
Thanks for listening.


RE: helper -> call to undefined function - InsiteFX - 05-11-2022

If your calling the helper in an html form etc; Then you need to load the helper in the html.

PHP Code:
<?php helper('yourHelperName'); ?>

See if that will work for you.


RE: helper -> call to undefined function - kenjis - 05-11-2022

(05-11-2022, 12:44 AM)InsiteFX Wrote: If your calling the helper in an html form etc; Then you need to load the helper in the html.

It is not true. You can also load the helper in controllers.

It works on local, but does not work on the server,
so maybe the helper filename (lower/uppercase)?

The filename and the code is the exactly same as you wrote?
'mylib'
mylib_helper.php


RE: helper -> call to undefined function - Kor - 05-11-2022

Yes, the file name is the same in the code and on the file.
I even renamed the file to form_helper_php, which is a native helper of CI, in order to "extend it", as described in the documentation. It didn't work.

One thing to consider:

My localhost server is Windows with XAMPP.

The host I uploaded is Linux with Apache.

Could it be something related to file permission? I'll check on it and let you guys know it.


RE: helper -> call to undefined function - InsiteFX - 05-12-2022

Thats the same setup I run and everything works file. Only difference on mine is that they
use public_html and not public. I also use VHosts.

So when coding I rename the public folder to public_html. Then just upload everything into the root of the server.

If you use spark then you need to change public to public_html in the path to the front controller.


RE: helper -> call to undefined function - Kor - 05-18-2022

Hello everyone.

Thank you for your insights and assistance.

The thing is, it had nothing to do with the helper file, but with the controller file name.
Since I uploaded my project to a Linux file system, which is case sensitive regarding file names, my controllers with composite names like "CheckOut" had to be renamed as "Checkout".

Anyways, everything is working just fine now.

Once again, thanks for all your help.


RE: helper -> call to undefined function - InsiteFX - 05-18-2022

This must be a server setup problem, because my site runs Linux also and it will except filenames like BaseController etc;