Class Phalcon\\UserPlugin\\Plugin\\Security not found

Hi,

I'm attempting to implement the PhalconUserPlugin.

So far I've installed a fresh copy of Phalcon and created a couple of controllers, views and models using the phalcon command line tools. With the exception of setting up database credentials, I've not altered any other files, such as those in config/.

I've installed the plugin with composer and can see the files in vendor/crada/phalcon-user-plugin.

I've added the following lines to config/services.php:

<?php 

...
use Phalcon\UserPlugin\Plugin\Security as SecurityPlugin;
use Phalcon\Mvc\Dispatcher;
use Phalcon\Events\Manager as EventsManager;
use Phalcon\UserPlugin\Auth\Auth;
use Phalcon\UserPlugin\Acl\Acl;
use Phalcon\UserPlugin\Mail\Mail;

...

$di->setShared(
    'dispatcher',
    function() use ($di) {
        $eventsManager = $di->getShared('eventsManager');

        $security = new SecurityPlugin($di);
        $eventsManager->attach('dispatch', $security);

        $dispatcher = new Dispatcher();
        $dispatcher->setEventsManager($eventsManager);

        return $dispatcher;
    }
  );

  ...

If I then try to reload in the browser any of my previously working controllers, I get the below error:

PHP Fatal error: Uncaught Error: Class 'Phalcon\UserPlugin\Plugin\Security' not found in /var/www/html/confab/app/config/services.php:45\nStack trace:\n#0 [internal function]: Closure->{closure}()\n#1 [internal function]: Phalcon\Di\Service->resolve(NULL, Object(Phalcon\Di\FactoryDefault))\n#2 [internal function]: Phalcon\Di->get('dispatcher', NULL)\n#3 [internal function]: Phalcon\Di->getShared('dispatcher')\n#4 /var/www/html/confab/public/index.php(42): Phalcon\Mvc\Application->handle()\n#5 {main}\n thrown in /var/www/html/confab/app/config/services.php on line 45

I looked through the closed issues on the plugins github. There was a complete example services.php posted, but only for earlier vesions of Pahlcon.

Any pointers would be appreciated.

Cheers,

edited Oct '17

This means such class doesn't exist/you didn't register it with loader.

edited Oct '17

Thanks, Wojciech. You were correct. I assumed that composer would have been autoloaded by phalcon automatically. I've not included the composer autoloader and the class is found.

Cheers