0

I've run into a problem when transfering files from a WAMP production environment to a LAMP staging/live environment.

In Yii, classes have to be named the same as their filenames so that they can be auto loaded.

The problem is that if the filename is the same but with a different case then it works on windows but not on linux. How can I force WAMP to check for case sensitivity in the filename before it gets to the LAMP server?

SystemicPlural
  • 5,629
  • 9
  • 49
  • 74

1 Answers1

0

WAMP has nothing to do with names case. You need to pay attention when you create files. Naming convention is very important, as in larger projects you might get lost if your class/file names are inconsistent.

Also check your file transfer tool, sometimes there are some setting to rename files to lowercase etc.

EDIT: Well, you could use CFileHelper::findFiles(Yii::getPathOfAlias('application'), array('fileTypes' => array('php'))), then compare filename with class name. To get class name without including it, use below code snippet from this answer:

$fp = fopen($file, 'r');
$class = $buffer = '';
$i = 0;
while (!$class) {
    if (feof($fp)) break;

    $buffer .= fread($fp, 512);
    $tokens = token_get_all($buffer);

    if (strpos($buffer, '{') === false) continue;

    for (;$i<count($tokens);$i++) {
        if ($tokens[$i][0] === T_CLASS) {
            for ($j=$i+1;$j<count($tokens);$j++) {
                if ($tokens[$j] === '{') {
                    $class = $tokens[$i+2][1];
                }
            }
        }
    }
}

Side note: To avoid bugs, use decent IDE like Eclipse or NetBeans and use new PHP Class instead of new PHP File option.

Community
  • 1
  • 1
  • Sorry, didn't phrase the title very well. It is the change from Windows to Linux that causes the problem. I do name things consistently, but bugs still creep in. I just want to know how to get them to throw an error whilst developing in windows when they are much easier to fix, rather than after transferring files to the linux box. – SystemicPlural Aug 23 '13 at 11:01