We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

phalcon framework

I am using phalcon multiple module.. and

Fatal error: Uncaught exception 'Phalcon\Mvc\Dispatcher\Exception' with message 'Okul\Frontend\Controllers\Login1Controller handler class cannot be loaded.. I get this error..
Can help me please..
Folder Structure
apps
    backend
    frontend
    library
    plugins
public
    index.php

    my index.php file

```php
<?php

error_reporting(E_ALL);

use Phalcon\Loader;
use Phalcon\Mvc\Router;
use Phalcon\DI\FactoryDefault;
use Phalcon\Mvc\Application as BaseApplication;

class Application extends BaseApplication
{

    /**
     * Register the services here to make them general or register in the ModuleDefinition to make them module-specific
     */
    protected function registerServices()
    {

        $di = new FactoryDefault();

        $loader = new Loader();

        /**
         * We're a registering a set of directories taken from the configuration file
         */
        $loader->registerDirs(
            array(
                __DIR__ . '/../apps/library/'
            )
        )->register();
                $di->set('dispatcher', function() {

    $eventsManager = new \Phalcon\Events\Manager();

    $eventsManager->attach("dispatch:beforeException", function($event, $dispatcher, $exception) {

        //Handle 404 exceptions
        if ($exception instanceof \Phalcon\Mvc\Dispatcher\Exception) {
            $dispatcher->forward(array(
                'controller' => 'index',
                'action' => 'show404'
            ));
            return false;
        }

        //Handle other exceptions
        $dispatcher->forward(array(
            'controller' => 'index',
            'action' => 'show503'
        ));

        return false;
    });

    $dispatcher = new \Phalcon\Mvc\Dispatcher();

    //Bind the EventsManager to the dispatcher
    $dispatcher->setEventsManager($eventsManager);

    return $dispatcher;

}, true);

        //Registering a router
        $di->set('router', function(){

            $router = new Router();

            $router->setDefaultModule("frontend");

            $router->add('/:controller/:action', array(
                'module' => 'frontend',
                'controller' => 1,
                'action' => 2,
            ));

            $router->add("/login", array(
                'module' => 'backend',
                'controller' => 'login',
                'action' => 'index',
            ));

            $router->add("/admin/products/:action", array(
                'module' => 'backend',
                'controller' => 'products',
                'action' => 1,
            ));

            $router->add("/products/:action", array(
                'module' => 'frontend',
                'controller' => 'products',
                'action' => 1,
            ));

            return $router;

        });

        $this->setDI($di);
    }

    public function main()
    {

        $this->registerServices();

        //Register the installed modules
        $this->registerModules(array(
            'frontend' => array(
                'className' => 'Okul\Frontend\Module',
                'path' => '../apps/frontend/Module.php'
            ),
            'backend' => array(
                'className' => 'Okul\Backend\Module',
                'path' => '../apps/backend/Module.php'
            )
        ));

        echo $this->handle()->getContent();
    }

}

$application = new Application();
$application->main();

MY BACKEND MODULE.PHP FİLE

<?php

namespace Okul\Backend;
use Phalcon\Session\Adapter\Files as PhalconSezon;
use Phalcon\Loader;
use Phalcon\Mvc\View;
use Phalcon\Mvc\Dispatcher;
use Phalcon\DiInterface;
use Phalcon\Db\Adapter\Pdo\Mysql as Database;
use Phalcon\Flash\Session as FlashSession;
use Phalcon\Events\Manager as EventsManager;
class Module {

    public function registerAutoloaders() {

        $loader = new Loader();

        $loader->registerNamespaces(array(
            'Okul\Backend\Controllers' => __DIR__.'/controllers/',
            'Okul\Backend\Models' => __DIR__.'/models/',
            'Okul\Backend\Plugins' => __DIR__.'/plugins/',
            'Okul\Backend\Library' => __DIR__.'/library/',

        ));

        $loader->register();
    }

    /**
     * Register the services here to make them general or register in the ModuleDefinition to make them module-specific
     */
    public function registerServices(DiInterface $di) {

        //Registering a dispatcher
        $di->set('dispatcher', function() {
            $dispatcher = new Dispatcher();
            $dispatcher->setDefaultNamespace("Okul\Backend\Controllers\\");
            return $dispatcher;
        });

        //Registering the view component
        $di->set('view', function() {
            $view = new \Phalcon\Mvc\View();
            $view->setViewsDir(__DIR__.'/views/');
            $view->registerEngines(array(
                ".volt" => 'Phalcon\Mvc\View\Engine\Volt'
            ));
            return $view;
        });

        //Set a different connection in each module
        $di->set('db', function() {
            return new Database(array(
                "host" => "localhost",
                "username" => "root",
                "password" => "",
                "dbname" => "ihlamurokullari"
            ));
        });

        $di->setShared('sezon', function() {
            $session = new PhalconSezon;
            $session->start();
            return $session;
        });
    }

}

AND FRONTEND MODULE.PHP

<?php

namespace Okul\Frontend;

use Phalcon\Session\Adapter\Files as PhalconSezon;
use Phalcon\Loader;
use Phalcon\Mvc\Dispatcher;
use Phalcon\Db\Adapter\Pdo\Mysql;

class Module {

    public function registerAutoloaders() {

        $loader = new Loader();

        $loader->registerNamespaces(array(
            'Okul\Frontend\Controllers' => __DIR__.'/controllers/',
            'Okul\Frontend\Models' => __DIR__.'/models/',
            'Okul\Frontend\Plugins' => __DIR__.'/plugins/',
        ));

        $loader->register();
    }

    /**
     * Register the services here to make them general or register in the ModuleDefinition to make them module-specific
     */
    public function registerServices($di) {

        //Registering a dispatcher
        $di->set('dispatcher', function () {
            $dispatcher = new Dispatcher();

            //Attach a event listener to the dispatcher
            $eventManager = new \Phalcon\Events\Manager();
            $eventManager->attach('dispatch', new \Acl('frontend'));

            $dispatcher->setEventsManager($eventManager);
            $dispatcher->setDefaultNamespace("Okul\Frontend\Controllers\\");
            return $dispatcher;
        });

        //Registering the view component
        $di->set('view', function () {
            $view = new \Phalcon\Mvc\View();
            $view->setViewsDir(__DIR__.'/views/');
            $view->registerEngines(array(
                ".volt" => 'Phalcon\Mvc\View\Engine\Volt'
            ));
            return $view;
        });

        $di->set('db', function () {
            return new Database(array(
                "host" => "localhost",
                "username" => "root",
                "password" => "",
                "dbname" => "ihlamurokullari"
            ));
        });

        $di->setShared('session', function() {
            $session = new PhalconSezon();
            $session->start();
            return $session;
        });
    }

}

HELP ME PLEASE....

Try removing the 404/502 exceptions