[SOLVED] Trying to use auth class - not found

I am trying to replicate the Auth class more or less from Vokuro. Added these lines to my project's app/config/services.php:

at the top:

use test\Auth\Auth;

at the bottom:

$di->set('auth', function () {
    return new Auth();

inside app/plugins I have a file called Auth.php:

namespace test\Auth;

use Phalcon\Mvc\User\Component;

use test\Models\Users
use test\Models\RememberTokens;
use test\Models\SuccessLogins;
use test\Models\FailedLogins;

class Auth extends Component{

And I am getting :

PHP Fatal error: Class 'test\Auth\Auth' not found in /var/www/html/test/app/config/services.php on line 96

Any ideas? Do I need to register the "plugins" directory somewhere? What am I missing? TIA!


If you do not register the plugin directory (in the place where you register models, controllers ... directories), phalcon will never find your Auth class


contents of app/config/config.php:


return new \Phalcon\Config(array(
    'database' => array(
        'adapter'     => 'Mysql',
        'host'        => 'localhost',
        'username'    => 'root',
        'password'    => '123456',
        'dbname'      => 'medonc',
    'application' => array(
        'controllersDir' => __DIR__ . '/../../app/controllers/',
        'modelsDir'      => __DIR__ . '/../../app/models/',
        'viewsDir'       => __DIR__ . '/../../app/views/',
        'pluginsDir'     => __DIR__ . '/../../app/plugins/',
        'libraryDir'     => __DIR__ . '/../../app/library/',
        'cacheDir'       => __DIR__ . '/../../app/cache/',
        'baseUri'        => '/test/',

Is there something else that I need to do to register the plugins directory?

In your bootstrap file, you need to loop through the application array and register each directory as a place the autoloader should look.



inside test/app/config/loader.php I changed




and that did it. Thanks!