[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.
[eluser]OliverHR[/eluser]
Why "MY_" ??
check for case sensitivity.
[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_';
[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"
[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'.
[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.
[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"
[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.