Welcome Guest, Not a member yet? Register   Sign In
Ready to go live, but helpers won't load! [SOLVED]
#1

[eluser]CoderReborn[/eluser]
After developing my PHP/CI project on my Mac, I'm finally ready to live!
Things have been running great while testing locally.
I installed CI 1.7.2 on a hosted server (running Ubuntu Lucid), uploaded my code, but am getting the following error when I load the site on the Internet.

"An Error Was Encountered
Unable to load the requested file: helpers/my_model_helper.php"

"MY_model_helper.php" is a custom helper in my /system/application/helpers directory.
Curious that the error msg does not capitalize "my".
I don't get this error when running CI 1.7.2 on my Mac.
By setting breakpoints, I found that my program dies in /system/codeigniter/CodeIgniter.php, line 201 ("CI = new $class();")

Thoughts on how to fix this?

Thanks.
#2

[eluser]OliverHR[/eluser]
Why "MY_" ??

check for case sensitivity.
#3

[eluser]CoderReborn[/eluser]
I chose "MY_" because it is the standard prefix when extending helpers.

In /system/application/config/config.php, the default setting is:
$config['subclass_prefix'] = 'MY_';
#4

[eluser]cahva[/eluser]
[quote author="CoderReborn" date="1285735349"]I chose "MY_" because it is the standard prefix when extending helpers.
[/quote]
Yes, but CI doesnt have model helper at all so you can just name it model_helper.php and load it with:
Code:
$this->load->helper('model');

It just came to my mind.. Did you try to load the helper with MY_ in that load?:
Code:
$this->load->helper('MY_model');

If the answer is yes then that's the problem. Don't add MY_ when loading helpers, libs etc. as CI will try to load using subclass_prefix + name.

I dont use Mac but if it has case-insensitive filesystem, then the load would work with my_model_helper also, just like with win-filesys(NTFS).
#5

[eluser]CoderReborn[/eluser]
I have the following line in my autoload file:

$autoload['helper'] = array('MY_model_helper', 'MY_array_helper', 'MY_string_helper', 'url', 'form', 'string', 'date', 'cookie');

This has been working fine on my Mac for months.
I believe that I have to specify the "MY_" prefix since I'm specifying that "MY_array_helper" (custom) needs to be autoloaded.
"array_helper" is already loaded by the system.

But for some reason, I'm running into a fatal error msg (in my first post), when I deployed on a hosted server.

If I remove "MY_model_helper" in the autoload file above, then I just get the following error:

"An Error Was Encountered
Unable to load the requested file: helpers/my_model_helper.php"
#6

[eluser]cahva[/eluser]
That's the problem then. Your autoload should look like:
Code:
$autoload['helper'] = array('model', 'array', 'string', 'url', 'form', 'string', 'date', 'cookie');
#7

[eluser]WanWizard[/eluser]
No, the problem is mentioned earlier in this thread.

For all these helpers, a CI version exists, so you have to name your extension MY_helpername to have it autoloaded. However, there is no CI helper called 'model', so the loader class will never start looking for a MY_ version, it already fails on the first load.

Only use the MY_ prefix if you extend CI functionality. If you create new files, in this case a helper, just call it 'model_helper.php', and then it will load fine when you load it as 'model'.
#8

[eluser]cahva[/eluser]
I just presumed that he fixed the problem that I said in my earlier post about the MY_model so thats why I didnt pay attention to that model helper in later post. Main point of my latter post was that he included MY_ and _helper when autoloading helpers, which is wrong.
#9

[eluser]CoderReborn[/eluser]
Thanks everyone!
Problem solved.

Here's a summary of my changes:

1) autoload.php changes

$autoload['helper'] = array('model_helper', 'my_array_helper', 'my_string_helper', 'my_cookie_helper', 'my_form_helper', 'url', 'form', 'string', 'date', 'cookie');

2) config.php changes

$config['subclass_prefix'] = 'my_';

3) I changed the public Linux (Ubuntu) permissions for these files to "r-x"
#10

[eluser]cahva[/eluser]
It's good that you got it working but please read my earlier posts as those changes you made should not be necessary. Autoload should work normally without using "my_" and "_helper" in that array as the load function will add those automatically(it first checks for the system helper, then searches for subclass_prefix + helpername + _helper). Your way works with helpers as they are simple functions but proabably not with libraries if you ever need to extend them.




Theme © iAndrew 2016 - Forum software by © MyBB