darsain / laravel-console

In-browser console for Laravel PHP framework.
170 stars 44 forks source link

Undefined method Console::attach() #7

Closed rk closed 11 years ago

rk commented 11 years ago

OSX 10.6.8 Apache 2.2.22 PHP 5.3.15

When I direct my browser to /console I receive the following exception:

Unhandled Exception

Message:

Call to undefined method Console::attach()

Location:

/Users/woodstreet/Sites/star-communities/bundles/console/start.php on line 42

To work around this (for the time being), I just mapped the class by hand. So something is going on with Autoloading this class.

Autoloader::map(array(
    'Console' => Bundle::path('console') . 'models/console.php',
));
markwu commented 11 years ago

Weird, I don't have this problem. I go through the source code, it seems the model already autoload in console/start.php

Autoloader::directories(array(
    Bundle::path('console').'models'
));

Mark

darsain commented 11 years ago

Do you have some other library with name Console loaded, or aliased? Because the bundle is working just fine. The models folder is added to the autoloader, and Console model is being loaded properly.

rk commented 11 years ago

That's a really good point, I do have another object that I use in my CLI tasks that will do things like terminal colors, etc. So this could be as simple as a naming conflict. I'll reopen if I find it isn't a naming conflict.

Maybe Laravel could have a "disambiguation" warning in case of multiple class files around the a single class name.

darsain commented 11 years ago

You probably do :) It is not reporting that Console class doesn't exist, it reports that attach() method is missing. That means that Console class is loaded, but it's not the correct one.

rk commented 11 years ago

Well, the weird thing is that since you updated your bundle to autoload its class the system broke. Before this latest version it worked (because mine was autoloaded too). So I never thought twice about it.

Thanks for the tip. :)

darsain commented 11 years ago

Before this update there was no autoloading model, it was all clusterfucked into controller.