fuel / core

Fuel PHP Framework - The core of the Fuel v1 framework
http://fuelphp.com
813 stars 345 forks source link

Modules routing issue #68

Closed zbrox closed 13 years ago

zbrox commented 13 years ago

I had a module which routes were doing fine, until some update from the git repo. Unfortunately I haven't notice which one was it :) The problem is find_controller method in Router always returns false on module controllers. In my case I'm expecting this line

if (class_exists(ucfirst($match->module).'\\Controller_'.ucfirst($match->controller)))

to return true, but it seems the autoloader hasn't loaded the proper controller filename (judging by what the profile shows as included files).

zbrox commented 13 years ago

Just wanted to add that including the controller file manually makes everything run ok, so I guess the autoloader is at fault.

zbrox commented 13 years ago

I found the bug in the autoloader. In the Autoloader core class on line 244

$file_path = strtolower($path.substr($namespace, strlen($ns) + 1).DS.str_replace('_', DS, $class_no_ns).'.php');

should be

$file_path = $path.strtolower(substr($namespace, strlen($ns) + 1).DS.str_replace('_', DS, $class_no_ns).'.php');
crynobone commented 13 years ago

Did you somehow name your Module with uppercase for the first letter?

By right FuelPHP require all filename or directory to be lowercase. http://fuelphp.com/blog/2011/04/classnames-autoloading-namespaces

zbrox commented 13 years ago

Yes, I know that. All of the files in my fuel app are lowercase. However not all folders in the full path are lowercase. For example Mac OS X home directory is /Users/username. By taking out the $path outside of the strtolower we're just lowercasing the part of the folder/file structure which is part of the fuel app installation.

zbrox commented 13 years ago

Also, I forgot to mention - maybe the first DS here is not needed. From what I saw putting it there leaves a double slash in the full path.

crynobone commented 13 years ago

Any chance your using MAMP?

Test on Zend Server CE on Mac

Mior-Muhammad-Zakis-iMac:htdocs crynobone$ php -a Interactive shell

php > var_dump(is_file('/Users/crynobone/htdocs/fuel/core/base.php')); bool(true) php > var_dump(is_file('/users/crynobone/htdocs/fuel/core/base.php')); bool(true) php >

zbrox commented 13 years ago

No, but maybe your filesystem is not case-sensitive. I can't remember well, but if I do recall correctly the default Mac OS X filesystem is journaled but not case sensitive. I've recently upgraded my hard drive and this time I chose to format it as HFS+ (but case-sensitive). Maybe if I hadn't I would've seen the problem. This will be a problem too if you're using ext3, ext4, reiserfs, etc, but I don't have a linux box now to test it. I'm preparing a pull request and we can continue the discussion there.

zbrox commented 13 years ago

I've issued a pull request so I'm closing this issue.