Domanda

I'm having a bit of trouble with autoloader configuration for a bundle I'm writing.

I have the following classes:

  • Ravenly\Models\RavenUser in models/raven_user.php
  • Ravenly\Ravenly in ravenly.php

I am trying to do the following:

$exists = call_user_func($class.'::where_crsid', $crsid)->count() > 0;

But I get the following error:

call_user_func() expects parameter 1 to be a valid callback, class 'Ravenly\Models\RavenUser' not found

I have tried setting $class (which is set in a config file) to "Models\RavenUser" as well, but I get the same error. I have my autoloader configured as follows:

Autoloader::namespaces(array(
    'Ravenly'           =>  Bundle::path('ravenly')
));

I don't understand why it's not working...

È stato utile?

Soluzione

The file name must match the class name. Your file should be named ravenuser.php

http://phpmaster.com/autoloading-and-the-psr-0-standard/

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top