CodeIgniter Forums
Strange case sensitive problem with autoload own libraries - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=11)
+--- Thread: Strange case sensitive problem with autoload own libraries (/showthread.php?tid=66696)



Strange case sensitive problem with autoload own libraries - chrobaks - 11-22-2016

Try to load a library 'MY_Userbundle.php' with
the autoload config.

The class name of 'MY_Userbundle.php' is 'class MY_Userbundle' .

When i do this in my localhost with :


Code:
$autoload['libraries'] = array('my_userbundle');

everything is fine,  but if i try this on my productionserver,
i get this error:

Unable to load the requested class: My_userbundle

when i change on production server to :

Code:
$autoload['libraries'] = array('MY_Userbundle');

everything is also fine.

Im working with the prefix 'MY_' and when i rename the MY_Userbundle.php
into Bundle.php and also renam the class MY_Userbundle in  class Bundle and
than do this in config_autoload :

Code:
$autoload['libraries'] = array('userbundle');

everything is also fine.

Why my local settings don't run on the production server?
What is going on here?


RE: Strange case sensitive problem with autoload own libraries - ciadmin - 11-23-2016

The use of MY_ as a class prefix is specifically intended for extending native CodeIgniter libraries.
Eg. $this->load->library('banana') will look for application/libraries/Banana.php, application/libraries/MY_Banana.php and system/libraries/CI_Banana.php.

If you ask for $this->load->('my_banana'), CI will look for application/libraries/My_banana.php, application/libraries/MY_My_banana.php and system/libraries/CI_My_banana.php.

On Windows, 'MY_Banana' would match any case, eg My_bAnAnA.php, whereas on Linux, CI will look for My_banana.php, making something appear to work locally although it fails on a production server.


Thanks for quick response - chrobaks - 11-23-2016

It was my mistake, to think that all chars are convert to lower case.
If i have a Class UserBundle, than i must take care of the 'B' in UserBundle
and load it like this, when im on a unix-system :

Code:
$autoload['libraries'] = array('userBundle');



RE: Strange case sensitive problem with autoload own libraries - Wouter60 - 11-23-2016

Please, read the documentation about libraries:
http://www.codeigniter.com/userguide3/general/creating_libraries.html

You will learn that the file must have a first capital letter, and that libraries are loaded with lower case only (in fact, the loading mechanism is case-insensitive, but the .php file name isn't!).