Welcome Guest, Not a member yet? Register   Sign In
CI acts differently between servers
#1

[eluser]newbrand[/eluser]
Hi there,

I've been developing a site on my local machine - all works fine. It's using PHP5, my production server is also on PHP5 (on a MediaTemple Grid Server). I just ported it online and a majority of the functionality works with some minor issues with libraries.

Basically I created my own class and dropped it in libraries/NameConverter.php. Here is a sample of the code:

Code:
<?php

class NameConverter {

    function convert($str) {
        // Does stuff...
        return $str;
    }
    
}

?>

I do a normal $this->load->library("nameconverter") and it works locally but online it reads out:

An Error Was Encountered

Unable to load the requested class: nameconverter

The weird thing is that I'm using the CI_Template class in my code and that seems to be working and importing correctly - doesn't read out any errors and does its job.

I'm itching to track down what I'm doing wrong :-(

Thanks in advance.

Dave
#2

[eluser]Eric Cope[/eluser]
Have you confirmed you uploaded the file to the site in the proper location? I make those types of easy errors more often than I care to admit.
#3

[eluser]meigwilym[/eluser]
Check the case of the filename, that could also be it.

Mei
#4

[eluser]got 2 doodle[/eluser]
Ya, check the case especially if you are developing on a windows machine and uploading to linux.

doodle
#5

[eluser]cahva[/eluser]
Yeah windows filesystem does not care if filename has uppercase letters but *nix/linux does, so change them all to lowercase.
#6

[eluser]Colin Williams[/eluser]
Reread the user guide section on creating custom libraries. It presents conventions for naming your libraries. You'll quickly see how you are not following the conventions you ought to.
#7

[eluser]newbrand[/eluser]
Yeah all the naming was correct. File in libraries/NameConverter.php. I'm going from a OS X system using MAMP to a CentOS Linux distro. The production server sometimes has file access issues as I believe I've seen before, but all the references are correct. Furthermore, when I installed the Template library that seems to work perfectly.


The user manual says I have to have a constructor to pass variables. I just included that...and nothing. Undecided
#8

[eluser]Colin Williams[/eluser]
Well, I'll be damned. The user guide ought to mention that the first letter AND ONLY THE FIRST LETTER of the filename should be capitalized. Use Name_converter.php and class Name_converter {} (or Nameconverter.php / class Nameconverter {} if you hate underscores, and readability)

The fact that the Template library is prefixed CI_ has to do with different conventions altogether.
#9

[eluser]newbrand[/eluser]
Oh, ok I see what's happening. My prduction server is assuming case sensitivity while my local is not. On the production serv it's using the convention of first letter which in essence breaks the load library.

So I guess it's not my fault? :-p I do have a habit of not reading user guides 100% before implementing but I honestly thought I had it all right. For future reference if something is in the manual that I miss, don't hesitate to smack me with a trout or a similar fish-like object.

:-p
#10

[eluser]Colin Williams[/eluser]
Quote:My prduction server is assuming case sensitivity while my local is not

You're almost there. Nothing is assuming anything. Your Unix server is case sensitive. Your Windows server is not.

Quote:On the production serv it’s using the convention of first letter which in essence breaks the load library.

The convention is the same regardless. It just so happens that on windows, if you don't follow the convention to the letter, you're still safe. Not true on Unix.

Quote:So I guess it’s not my fault?

Well, it is your fault. You named your file and class incorrectly.




Theme © iAndrew 2016 - Forum software by © MyBB