protected function initPhalconApplication()
    {
        $diFactory     = $this->diManager->getDI();
        $moduleHandler = $diFactory->get('moduleHandler');

        // Register autoloader
        (new Autoloader($diFactory))->register();

        // Register services and routers
        $this->diManager->initInvokableServices()
                ->initFactoriedServices()
                ->initRouterDi();

        // Init listeners
        (new Listener($diFactory))
                ->listenApplicationEvents(new Listener\Application())
                ->listenDispatchEvents(new Listener\Dispatch());

        // Register modules
        $application = new PhalconApplication($diFactory);
        $application->setEventsManager($diFactory['eventsManager']);
        $application->registerModules($moduleHandler->getRegisteredModules());

        return $application;
    }