Welcome Guest, Not a member yet? Register   Sign In
helper -> call to undefined function
#1

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

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

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

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

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

(This post was last modified: 05-12-2022, 01:06 AM by InsiteFX.)

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

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

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

This must be a server setup problem, because my site runs Linux also and it will except filenames like BaseController etc;
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB