Phalcon Framework 3.3.2

Phalcon\Mvc\Dispatcher\Exception: Index\Controller\IndexController handler class cannot be loaded

/home/anquanhday/cms/app/Bootstrap.php (373)
#0Phalcon\Mvc\Dispatcher->_throwDispatchException(Index\Controller\IndexController handler class cannot be loaded, 2)
#1Phalcon\Dispatcher->dispatch()
/home/anquanhday/cms/app/Bootstrap.php (373)
<?php
 
namespace PhalartCMS;
use Application\Cache\Manager as CacheManager;
use Cms\Model\Configuration as CmsConfiguration;
use \PhalartCMS\Plugin\CheckPoint as CheckPointPlugin;
use \PhalartCMS\Plugin\Localization as LocalizationPlugin;
use \PhalartCMS\Plugin\AdminLocalization as AdminLocalizationPlugin;
use \PhalartCMS\Plugin\Acl as AclPlugin;
use \PhalartCMS\Plugin\MobileDetect as MobileDetectPlugin;
use \PhalartCMS\Plugin\Title as TitlePlugin;
 
/**
 * @copyright Copyright (c) 2018 Phalart
 * @author Nhan Phong <nhanphong@vinadesign.vn>
 * User: nhanphong
 * Date: 6/4/18
 * Time: 10:51 AM
 */
 
if (APPLICATION_ENV == 'development') {
    date_default_timezone_set('Asia/Bangkok');
    ini_set('display_errors', true);
    error_reporting(E_ALL);
}
define('ROOT_APP', __DIR__);
 
class Bootstrap
{
 
    public function run()
    {
        $di = new \Phalcon\DI\FactoryDefault();
 
        $application = include_once APPLICATION_PATH . '/config/environment/' . APPLICATION_ENV . '.php';
 
        $config_default = [
            'base_path' => (isset($application['base_path'])) ? $application['base_path'] : null,
            'base_uri' => (isset($application['base_uri'])) ? $application['base_uri'] : null,
            'database'  => (isset($application['database'])) ? $application['database'] : null,
            'cache'     => (isset($application['cache'])) ? $application['cache'] : null,
            'memcache'  => (isset($application['memcache'])) ? $application['memcache'] : null,
            'memcached'  => (isset($application['memcached'])) ? $application['memcached'] : null,
            'assets'    => (isset($application['assets'])) ? $application['assets'] : null,
        ];
        $config = new \Phalcon\Config($config_default);
 
        // Database
        $db = new \Phalcon\Db\Adapter\Pdo\Mysql([
            "host"     => $config->database->host,
            "username" => $config->database->username,
            "password" => $config->database->password,
            "dbname"   => $config->database->dbname,
            "charset"  => $config->database->charset,
        ]);
        $di->set('db', $db);
        // Config
 
        $result = $db->fetchOne(
            "SELECT * FROM `cms_configuration` WHERE `key` = 'THEME'"
        );
        $theme = $result['value'];
        define('THEME', $theme);
        define('THEME_PATH', __DIR__ . '/themes/' . $theme);
        require_once LIBRARY_PATH . '/modules/Cms/ConfigApp.php';
        $config2 = \Cms\ConfigApp::get();
        $config->merge($config2);
        $di->set('config', $config);
 
        // Registry
        $registry = new \Phalcon\Registry();
        $di->set('registry', $registry);
 
        // Loader
        $loader = new \Phalcon\Loader();
        $loader->registerNamespaces($config->loader->namespaces->toArray());
        $loader->registerDirs([LIBRARY_PATH . "/plugins/"]);
        $loader->registerFiles([APPLICATION_PATH . '/../vendor/autoload.php']);
        $loader->register();
 
 
        // Get Option setting
        $di->set('options', new \PhalartCMS\Plugin\Options());
        // Get Option setting
 
        // View
        $this->initView($di);
        $this->initSimpleView($di);
 
        // URL
        $url = new \Phalcon\Mvc\Url();
        $url->setBasePath($config->base_path);
        $url->setBaseUri($config->base_path);
        $di->set('url', $url);
 
        // Cache
        $this->initCache($di);
 
        // CMS
        $cmsModel = new CmsConfiguration();
        $registry->cms = $cmsModel->getConfig(); // Отправляем в Registry
 
        // Application
        $application = new \Phalcon\Mvc\Application();
        $application->registerModules($config->modules->toArray());
 
        // Events Manager, Dispatcher
        $this->initEventManager($di);
 
        // Session
        $session = new \Phalcon\Session\Adapter\Files();
        $session->start();
        $di->set('session', $session);
 
        $acl = new \Application\Acl\DefaultAcl();
        $di->set('acl', $acl);
 
        // JS Assets
        $this->initAssetsManager($di);
 
        // Flash helper
        $flash = new \Phalcon\Flash\Session([
            'error'   => 'alert alert-danger',
            'success' => 'alert alert-success',
            'notice'  => 'alert alert-info',
            'warning' => 'alert alert-warning',
        ]);
        $flash->setAutoescape(false);
        $di->set('flash', $flash);
 
        $di->set('helper', new \Application\Mvc\Helper());
 
        // Routing
        $this->initRouting($application, $di);
 
        $application->setDI($di);
 
        // Main dispatching process
        $response = $this->dispatch($di);
        $response->send();
 
    }
 
    private function initRouting($application, $di)
    {
        $router = new \Application\Mvc\Router\DefaultRouter();
        $router->setDi($di);
        foreach ($application->getModules() as $module) {
            $routesClassName = str_replace('Module', 'Routes', $module['className']);
            if (class_exists($routesClassName)) {
                $routesClass = new $routesClassName();
                $router = $routesClass->init($router);
            }
            $initClassName = str_replace('Module', 'Init', $module['className']);
            if (class_exists($initClassName)) {
                new $initClassName();
            }
        }
        $di->set('router', $router);
    }
 
    private function initAssetsManager($di)
    {
        $config = $di->get('config');
        $assetsManager = new \Application\Assets\Manager();
        $js_collection = $assetsManager->collection('js')
            ->setLocal(true)
            ->addFilter(new \Phalcon\Assets\Filters\Jsmin())
            ->setTargetPath(ROOT . '/assets/js.js')
            ->setTargetUri('assets/js.js')
            ->join(true);
        if ($config->assets->js) {
            foreach ($config->assets->js as $js) {
                $js_collection->addJs(ROOT . '/' . $js);
            }
        }
 
        // Admin JS Assets
        $assetsManager->collection('modules-admin-js')
            ->setLocal(true)
            ->addFilter(new \Phalcon\Assets\Filters\Jsmin())
            ->setTargetPath(ROOT . '/assets/modules-admin.js')
            ->setTargetUri('assets/modules-admin.js')
            ->join(true);
 
        // Admin LESS Assets
        $assetsManager->collection('modules-admin-less')
            ->setLocal(true)
            ->addFilter(new \Application\Assets\Filter\Less())
            ->setTargetPath(ROOT . '/assets/modules-admin.less')
            ->setTargetUri('assets/modules-admin.less')
            ->join(true)
            ->addCss(APPLICATION_PATH . '/modules/Admin/assets/admin.less');
 
        $di->set('assets', $assetsManager);
    }
 
    private function initEventManager($di)
    {
        $eventsManager = new \Phalcon\Events\Manager();
        $dispatcher = new \Phalcon\Mvc\Dispatcher();
 
        $eventsManager->attach("dispatch:beforeDispatchLoop", function ($event, $dispatcher) use ($di) {
            new CheckPointPlugin($di->get('request'));
            new LocalizationPlugin($dispatcher);
            new AdminLocalizationPlugin($di->get('config'));
            new AclPlugin($di->get('acl'), $dispatcher, $di->get('view'));
            new MobileDetectPlugin($di->get('session'), $di->get('view'), $di->get('request'));
        });
 
        $eventsManager->attach("dispatch:afterDispatchLoop", function ($event, $dispatcher) use ($di) {
            new \Seo\Plugin\SeoManager($dispatcher, $di->get('request'), $di->get('router'), $di->get('view'));
            new TitlePlugin($di);
        });
 
        // Profiler
        $registry = $di->get('registry');
        if ($registry->cms['PROFILER']) {
            $profiler = new \Phalcon\Db\Profiler();
            $di->set('profiler', $profiler);
 
            $eventsManager->attach('db', function ($event, $db) use ($profiler) {
                if ($event->getType() == 'beforeQuery') {
                    $profiler->startProfile($db->getSQLStatement());
                }
                if ($event->getType() == 'afterQuery') {
                    $profiler->stopProfile();
                }
            });
        }
 
        $db = $di->get('db');
        $db->setEventsManager($eventsManager);
 
        $dispatcher->setEventsManager($eventsManager);
        $di->set('dispatcher', $dispatcher);
    }
 
    private function initView($di)
    {
        $view = new \Phalcon\Mvc\View();
        $theme = THEME;
        define('MAIN_VIEW_PATH', ROOT_APP . "/themes/{$theme}/views/");
 
        /*$view->setViewsDir(MAIN_VIEW_PATH);
        $view->setPartialsDir(MAIN_VIEW_PATH . "/partials/");
        $view->setRenderLevel(\Phalcon\Mvc\View::LEVEL_ACTION_VIEW);*/
 
        // Volt
        $volt = new \Application\Mvc\View\Engine\Volt($view, $di);
        $volt->setOptions([
            'compiledPath' => APPLICATION_PATH . '/../data/cache/volt/',
            'compileAlways'     => (APPLICATION_ENV == 'development'),
        ]);
        $volt->initCompiler();
 
 
        $phtml = new \Phalcon\Mvc\View\Engine\Php($view, $di);
        $viewEngines = [
            ".volt"  => $volt,
            ".phtml" => $phtml,
        ];
 
        $view->registerEngines($viewEngines);
 
        $ajax = $di->get('request')->getQuery('_ajax');
        if ($ajax) {
            $view->setRenderLevel(\Phalcon\Mvc\View::LEVEL_LAYOUT);
        }
 
        $di->set('view', $view);
 
        return $view;
    }
 
    private function initSimpleView($di)
    {
        $view = new \Phalcon\Mvc\View\Simple();
 
        // Volt
        $volt = new \Application\Mvc\View\Engine\Volt($view, $di);
        $volt->setOptions(['compiledPath' => APPLICATION_PATH . '/../data/cache/volt/']);
        $volt->initCompiler();
 
        $phtml = new \Phalcon\Mvc\View\Engine\Php($view, $di);
        $viewEngines = [
            ".volt"  => $volt,
            ".phtml" => $phtml,
        ];
 
        $view->registerEngines($viewEngines);
        $di->set('simpleView', $view);
 
        return $view;
    }
 
    private function initCache($di)
    {
        $config = $di->get('config');
 
        $cacheFrontend = new \Phalcon\Cache\Frontend\Data([
            "lifetime" => 60,
            "prefix"   => HOST_HASH,
        ]);
 
        $cache = null;
        switch ($config->cache) {
            case 'file':
                $cache = new \Phalcon\Cache\Backend\File($cacheFrontend, [
                    "cacheDir" => APPLICATION_PATH . "/../data/cache/backend/"
                ]);
                break;
            case 'memcache':
                $cache = new \Phalcon\Cache\Backend\Memcache(
                    $cacheFrontend, [
                    "host" => $config->memcache->host,
                    "port" => $config->memcache->port,
                ]);
                break;
            case 'memcached':
                $cache = new \Phalcon\Cache\Backend\Libmemcached(
                    $cacheFrontend, [
                    "host" => $config->memcached->host,
                    "port" => $config->memcached->port,
                ]);
                break;
        }
        $di->set('cache', $cache, true);
        $di->set('modelsCache', $cache, true);
 
        \Application\Widget\Proxy::$cache = $cache; // Modules Widget System
 
        $modelsMetadata = new \Phalcon\Mvc\Model\Metadata\Memory();
        $di->set('modelsMetadata', $modelsMetadata);
 
        $di->set('cacheManager', new CacheManager());
    }
 
    private function dispatch($di)
    {
        $router = $di['router'];
 
        $router->handle();
 
        $view = $di['view'];
 
        $dispatcher = $di['dispatcher'];
 
        $response = $di['response'];
 
        $dispatcher->setModuleName($router->getModuleName());
        $dispatcher->setControllerName($router->getControllerName());
        $dispatcher->setActionName($router->getActionName());
        $dispatcher->setParams($router->getParams());
 
        $moduleName = \Application\Utils\ModuleName::camelize($router->getModuleName());
 
        $ModuleClassName = $moduleName . '\Module';
        
        if (class_exists($ModuleClassName)) {
            $module = new $ModuleClassName;
            $module->registerAutoloaders();
            $module->registerServices($di);
        }
 
        $view->start();
 
        $registry = $di['registry'];
        if ($registry->cms['DEBUG_MODE']) {
            $debug = new \Phalcon\Debug();
            $debug->listen();
 
            $dispatcher->dispatch();
        } else {
            try {
                $dispatcher->dispatch();
            } catch (\Phalcon\Exception $e) {
                // Errors catching
 
                $view->setViewsDir(__DIR__ . '/modules/Index/views/');
                $view->setPartialsDir('');
                $view->e = $e;
 
                if ($e instanceof \Phalcon\Mvc\Dispatcher\Exception) {
                    $response->setStatusCode(404, 'Not Found');
                    $view->partial('error/error404');
                } else {
                    $response->setStatusCode(503, 'Service Unavailable');
                    $view->partial('error/error503');
                }
 
                return $response;
            }
        }
 
        $view->render(
            $dispatcher->getControllerName(),
            $dispatcher->getActionName(),
            $dispatcher->getParams()
        );
 
        $view->finish();
 
        // AJAX
        $request = $di['request'];
        $_ajax = $request->getQuery('_ajax');
        if ($_ajax) {
            $contents = $view->getContent();
 
            $return = new \stdClass();
            $return->html = $contents;
            $return->title = $di->get('helper')->title()->get();
            $return->success = true;
 
            if ($view->bodyClass) {
                $return->bodyClass = $view->bodyClass;
            }
 
            $headers = $response->getHeaders()->toArray();
            if (isset($headers[404]) || isset($headers[503])) {
                $return->success = false;
            }
            $response->setContentType('application/json', 'UTF-8');
            $response->setContent(json_encode($return));
        } else {
            $response->setContent($view->getContent());
        }
 
        return $response;
    }
 
}
#2PhalartCMS\Bootstrap->dispatch(Object(Phalcon\Di\FactoryDefault))
/home/anquanhday/cms/app/Bootstrap.php (139)
<?php
 
namespace PhalartCMS;
use Application\Cache\Manager as CacheManager;
use Cms\Model\Configuration as CmsConfiguration;
use \PhalartCMS\Plugin\CheckPoint as CheckPointPlugin;
use \PhalartCMS\Plugin\Localization as LocalizationPlugin;
use \PhalartCMS\Plugin\AdminLocalization as AdminLocalizationPlugin;
use \PhalartCMS\Plugin\Acl as AclPlugin;
use \PhalartCMS\Plugin\MobileDetect as MobileDetectPlugin;
use \PhalartCMS\Plugin\Title as TitlePlugin;
 
/**
 * @copyright Copyright (c) 2018 Phalart
 * @author Nhan Phong <nhanphong@vinadesign.vn>
 * User: nhanphong
 * Date: 6/4/18
 * Time: 10:51 AM
 */
 
if (APPLICATION_ENV == 'development') {
    date_default_timezone_set('Asia/Bangkok');
    ini_set('display_errors', true);
    error_reporting(E_ALL);
}
define('ROOT_APP', __DIR__);
 
class Bootstrap
{
 
    public function run()
    {
        $di = new \Phalcon\DI\FactoryDefault();
 
        $application = include_once APPLICATION_PATH . '/config/environment/' . APPLICATION_ENV . '.php';
 
        $config_default = [
            'base_path' => (isset($application['base_path'])) ? $application['base_path'] : null,
            'base_uri' => (isset($application['base_uri'])) ? $application['base_uri'] : null,
            'database'  => (isset($application['database'])) ? $application['database'] : null,
            'cache'     => (isset($application['cache'])) ? $application['cache'] : null,
            'memcache'  => (isset($application['memcache'])) ? $application['memcache'] : null,
            'memcached'  => (isset($application['memcached'])) ? $application['memcached'] : null,
            'assets'    => (isset($application['assets'])) ? $application['assets'] : null,
        ];
        $config = new \Phalcon\Config($config_default);
 
        // Database
        $db = new \Phalcon\Db\Adapter\Pdo\Mysql([
            "host"     => $config->database->host,
            "username" => $config->database->username,
            "password" => $config->database->password,
            "dbname"   => $config->database->dbname,
            "charset"  => $config->database->charset,
        ]);
        $di->set('db', $db);
        // Config
 
        $result = $db->fetchOne(
            "SELECT * FROM `cms_configuration` WHERE `key` = 'THEME'"
        );
        $theme = $result['value'];
        define('THEME', $theme);
        define('THEME_PATH', __DIR__ . '/themes/' . $theme);
        require_once LIBRARY_PATH . '/modules/Cms/ConfigApp.php';
        $config2 = \Cms\ConfigApp::get();
        $config->merge($config2);
        $di->set('config', $config);
 
        // Registry
        $registry = new \Phalcon\Registry();
        $di->set('registry', $registry);
 
        // Loader
        $loader = new \Phalcon\Loader();
        $loader->registerNamespaces($config->loader->namespaces->toArray());
        $loader->registerDirs([LIBRARY_PATH . "/plugins/"]);
        $loader->registerFiles([APPLICATION_PATH . '/../vendor/autoload.php']);
        $loader->register();
 
 
        // Get Option setting
        $di->set('options', new \PhalartCMS\Plugin\Options());
        // Get Option setting
 
        // View
        $this->initView($di);
        $this->initSimpleView($di);
 
        // URL
        $url = new \Phalcon\Mvc\Url();
        $url->setBasePath($config->base_path);
        $url->setBaseUri($config->base_path);
        $di->set('url', $url);
 
        // Cache
        $this->initCache($di);
 
        // CMS
        $cmsModel = new CmsConfiguration();
        $registry->cms = $cmsModel->getConfig(); // Отправляем в Registry
 
        // Application
        $application = new \Phalcon\Mvc\Application();
        $application->registerModules($config->modules->toArray());
 
        // Events Manager, Dispatcher
        $this->initEventManager($di);
 
        // Session
        $session = new \Phalcon\Session\Adapter\Files();
        $session->start();
        $di->set('session', $session);
 
        $acl = new \Application\Acl\DefaultAcl();
        $di->set('acl', $acl);
 
        // JS Assets
        $this->initAssetsManager($di);
 
        // Flash helper
        $flash = new \Phalcon\Flash\Session([
            'error'   => 'alert alert-danger',
            'success' => 'alert alert-success',
            'notice'  => 'alert alert-info',
            'warning' => 'alert alert-warning',
        ]);
        $flash->setAutoescape(false);
        $di->set('flash', $flash);
 
        $di->set('helper', new \Application\Mvc\Helper());
 
        // Routing
        $this->initRouting($application, $di);
 
        $application->setDI($di);
 
        // Main dispatching process
        $response = $this->dispatch($di);
        $response->send();
 
    }
 
    private function initRouting($application, $di)
    {
        $router = new \Application\Mvc\Router\DefaultRouter();
        $router->setDi($di);
        foreach ($application->getModules() as $module) {
            $routesClassName = str_replace('Module', 'Routes', $module['className']);
            if (class_exists($routesClassName)) {
                $routesClass = new $routesClassName();
                $router = $routesClass->init($router);
            }
            $initClassName = str_replace('Module', 'Init', $module['className']);
            if (class_exists($initClassName)) {
                new $initClassName();
            }
        }
        $di->set('router', $router);
    }
 
    private function initAssetsManager($di)
    {
        $config = $di->get('config');
        $assetsManager = new \Application\Assets\Manager();
        $js_collection = $assetsManager->collection('js')
            ->setLocal(true)
            ->addFilter(new \Phalcon\Assets\Filters\Jsmin())
            ->setTargetPath(ROOT . '/assets/js.js')
            ->setTargetUri('assets/js.js')
            ->join(true);
        if ($config->assets->js) {
            foreach ($config->assets->js as $js) {
                $js_collection->addJs(ROOT . '/' . $js);
            }
        }
 
        // Admin JS Assets
        $assetsManager->collection('modules-admin-js')
            ->setLocal(true)
            ->addFilter(new \Phalcon\Assets\Filters\Jsmin())
            ->setTargetPath(ROOT . '/assets/modules-admin.js')
            ->setTargetUri('assets/modules-admin.js')
            ->join(true);
 
        // Admin LESS Assets
        $assetsManager->collection('modules-admin-less')
            ->setLocal(true)
            ->addFilter(new \Application\Assets\Filter\Less())
            ->setTargetPath(ROOT . '/assets/modules-admin.less')
            ->setTargetUri('assets/modules-admin.less')
            ->join(true)
            ->addCss(APPLICATION_PATH . '/modules/Admin/assets/admin.less');
 
        $di->set('assets', $assetsManager);
    }
 
    private function initEventManager($di)
    {
        $eventsManager = new \Phalcon\Events\Manager();
        $dispatcher = new \Phalcon\Mvc\Dispatcher();
 
        $eventsManager->attach("dispatch:beforeDispatchLoop", function ($event, $dispatcher) use ($di) {
            new CheckPointPlugin($di->get('request'));
            new LocalizationPlugin($dispatcher);
            new AdminLocalizationPlugin($di->get('config'));
            new AclPlugin($di->get('acl'), $dispatcher, $di->get('view'));
            new MobileDetectPlugin($di->get('session'), $di->get('view'), $di->get('request'));
        });
 
        $eventsManager->attach("dispatch:afterDispatchLoop", function ($event, $dispatcher) use ($di) {
            new \Seo\Plugin\SeoManager($dispatcher, $di->get('request'), $di->get('router'), $di->get('view'));
            new TitlePlugin($di);
        });
 
        // Profiler
        $registry = $di->get('registry');
        if ($registry->cms['PROFILER']) {
            $profiler = new \Phalcon\Db\Profiler();
            $di->set('profiler', $profiler);
 
            $eventsManager->attach('db', function ($event, $db) use ($profiler) {
                if ($event->getType() == 'beforeQuery') {
                    $profiler->startProfile($db->getSQLStatement());
                }
                if ($event->getType() == 'afterQuery') {
                    $profiler->stopProfile();
                }
            });
        }
 
        $db = $di->get('db');
        $db->setEventsManager($eventsManager);
 
        $dispatcher->setEventsManager($eventsManager);
        $di->set('dispatcher', $dispatcher);
    }
 
    private function initView($di)
    {
        $view = new \Phalcon\Mvc\View();
        $theme = THEME;
        define('MAIN_VIEW_PATH', ROOT_APP . "/themes/{$theme}/views/");
 
        /*$view->setViewsDir(MAIN_VIEW_PATH);
        $view->setPartialsDir(MAIN_VIEW_PATH . "/partials/");
        $view->setRenderLevel(\Phalcon\Mvc\View::LEVEL_ACTION_VIEW);*/
 
        // Volt
        $volt = new \Application\Mvc\View\Engine\Volt($view, $di);
        $volt->setOptions([
            'compiledPath' => APPLICATION_PATH . '/../data/cache/volt/',
            'compileAlways'     => (APPLICATION_ENV == 'development'),
        ]);
        $volt->initCompiler();
 
 
        $phtml = new \Phalcon\Mvc\View\Engine\Php($view, $di);
        $viewEngines = [
            ".volt"  => $volt,
            ".phtml" => $phtml,
        ];
 
        $view->registerEngines($viewEngines);
 
        $ajax = $di->get('request')->getQuery('_ajax');
        if ($ajax) {
            $view->setRenderLevel(\Phalcon\Mvc\View::LEVEL_LAYOUT);
        }
 
        $di->set('view', $view);
 
        return $view;
    }
 
    private function initSimpleView($di)
    {
        $view = new \Phalcon\Mvc\View\Simple();
 
        // Volt
        $volt = new \Application\Mvc\View\Engine\Volt($view, $di);
        $volt->setOptions(['compiledPath' => APPLICATION_PATH . '/../data/cache/volt/']);
        $volt->initCompiler();
 
        $phtml = new \Phalcon\Mvc\View\Engine\Php($view, $di);
        $viewEngines = [
            ".volt"  => $volt,
            ".phtml" => $phtml,
        ];
 
        $view->registerEngines($viewEngines);
        $di->set('simpleView', $view);
 
        return $view;
    }
 
    private function initCache($di)
    {
        $config = $di->get('config');
 
        $cacheFrontend = new \Phalcon\Cache\Frontend\Data([
            "lifetime" => 60,
            "prefix"   => HOST_HASH,
        ]);
 
        $cache = null;
        switch ($config->cache) {
            case 'file':
                $cache = new \Phalcon\Cache\Backend\File($cacheFrontend, [
                    "cacheDir" => APPLICATION_PATH . "/../data/cache/backend/"
                ]);
                break;
            case 'memcache':
                $cache = new \Phalcon\Cache\Backend\Memcache(
                    $cacheFrontend, [
                    "host" => $config->memcache->host,
                    "port" => $config->memcache->port,
                ]);
                break;
            case 'memcached':
                $cache = new \Phalcon\Cache\Backend\Libmemcached(
                    $cacheFrontend, [
                    "host" => $config->memcached->host,
                    "port" => $config->memcached->port,
                ]);
                break;
        }
        $di->set('cache', $cache, true);
        $di->set('modelsCache', $cache, true);
 
        \Application\Widget\Proxy::$cache = $cache; // Modules Widget System
 
        $modelsMetadata = new \Phalcon\Mvc\Model\Metadata\Memory();
        $di->set('modelsMetadata', $modelsMetadata);
 
        $di->set('cacheManager', new CacheManager());
    }
 
    private function dispatch($di)
    {
        $router = $di['router'];
 
        $router->handle();
 
        $view = $di['view'];
 
        $dispatcher = $di['dispatcher'];
 
        $response = $di['response'];
 
        $dispatcher->setModuleName($router->getModuleName());
        $dispatcher->setControllerName($router->getControllerName());
        $dispatcher->setActionName($router->getActionName());
        $dispatcher->setParams($router->getParams());
 
        $moduleName = \Application\Utils\ModuleName::camelize($router->getModuleName());
 
        $ModuleClassName = $moduleName . '\Module';
        
        if (class_exists($ModuleClassName)) {
            $module = new $ModuleClassName;
            $module->registerAutoloaders();
            $module->registerServices($di);
        }
 
        $view->start();
 
        $registry = $di['registry'];
        if ($registry->cms['DEBUG_MODE']) {
            $debug = new \Phalcon\Debug();
            $debug->listen();
 
            $dispatcher->dispatch();
        } else {
            try {
                $dispatcher->dispatch();
            } catch (\Phalcon\Exception $e) {
                // Errors catching
 
                $view->setViewsDir(__DIR__ . '/modules/Index/views/');
                $view->setPartialsDir('');
                $view->e = $e;
 
                if ($e instanceof \Phalcon\Mvc\Dispatcher\Exception) {
                    $response->setStatusCode(404, 'Not Found');
                    $view->partial('error/error404');
                } else {
                    $response->setStatusCode(503, 'Service Unavailable');
                    $view->partial('error/error503');
                }
 
                return $response;
            }
        }
 
        $view->render(
            $dispatcher->getControllerName(),
            $dispatcher->getActionName(),
            $dispatcher->getParams()
        );
 
        $view->finish();
 
        // AJAX
        $request = $di['request'];
        $_ajax = $request->getQuery('_ajax');
        if ($_ajax) {
            $contents = $view->getContent();
 
            $return = new \stdClass();
            $return->html = $contents;
            $return->title = $di->get('helper')->title()->get();
            $return->success = true;
 
            if ($view->bodyClass) {
                $return->bodyClass = $view->bodyClass;
            }
 
            $headers = $response->getHeaders()->toArray();
            if (isset($headers[404]) || isset($headers[503])) {
                $return->success = false;
            }
            $response->setContentType('application/json', 'UTF-8');
            $response->setContent(json_encode($return));
        } else {
            $response->setContent($view->getContent());
        }
 
        return $response;
    }
 
}
#3PhalartCMS\Bootstrap->run()
/home/anquanhday/cms/public/index.php (41)
<?php
 
/**
 * @copyright Copyright (c) 2018 Phalart
 * @author Nhan Phong <nhanphong@vinadesign.vn>
 * User: nhanphong
 * Date: 6/4/18
 * Time: 10:51 AM
 */
chdir(dirname(__DIR__));
 
define('ROOT', __DIR__);
define('HOST_HASH', substr(md5($_SERVER['HTTP_HOST']), 0, 12));
 
if (isset($_SERVER['APPLICATION_ENV'])) {
    $applicationEnv = ($_SERVER['APPLICATION_ENV'] ? $_SERVER['APPLICATION_ENV'] : 'production');
} else {
    $applicationEnv = (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production');
}
 
define('APPLICATION_ENV', $applicationEnv);
$actual_link = (isset($_SERVER['HTTPS']) ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
$parts = parse_url($actual_link);
$prefix = substr($parts['path'], 1);
$part = explode('/', $prefix);
$admin = 'admin';
$theme = 'blog';
//define('THEME', $theme);
if ($part[0] != $admin) {
    define('IS_ADMIN', false);
    define('APPLICATION_PATH', __DIR__ . '/../app');
    require_once APPLICATION_PATH . '/Bootstrap.php';
} else {
    define('IS_ADMIN', true);
    define('APPLICATION_PATH', __DIR__ . '/../admin');
    define('ADMINISTRATOR_PATH', __DIR__ . '/../admin');
    require_once ADMINISTRATOR_PATH . '/Bootstrap.php';
}
define('LIBRARY_PATH', __DIR__ . '/../library');
$bootstrap = new PhalartCMS\Bootstrap();
$bootstrap->run();
KeyValue
KeyValue
USERwww-data
HOME/var/www
HTTP_CONNECTIONclose
HTTP_IF_MODIFIED_SINCEWed, 20 Jun 2018 10:58:43 GMT
HTTP_ACCEPTtext/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
HTTP_USER_AGENTCCBot/2.0 (http://commoncrawl.org/faq/)
HTTP_ACCEPT_ENCODINGx-gzip, gzip, deflate
HTTP_HOSTcdnblog.muabannhanh.com
APPLICATION_ENVproduction
SCRIPT_FILENAME/home/anquanhday/cms/public/index.php
PATH_TRANSLATED/home/anquanhday/cms/public
PATH_INFO
REDIRECT_STATUS200
SERVER_NAMEanquanhday.com
SERVER_PORT443
SERVER_ADDR210.211.116.91
REMOTE_PORT38232
REMOTE_ADDR54.225.17.239
SERVER_SOFTWAREnginx/1.6.2
GATEWAY_INTERFACECGI/1.1
HTTPSon
SERVER_PROTOCOLHTTP/1.1
DOCUMENT_ROOT/home/anquanhday/cms/public
DOCUMENT_URI/index.php
REQUEST_URI/
SCRIPT_NAME/index.php
CONTENT_LENGTH
CONTENT_TYPE
REQUEST_METHODGET
QUERY_STRING
FCGI_ROLERESPONDER
PHP_SELF/index.php
REQUEST_TIME_FLOAT1532247725.3784
REQUEST_TIME1532247725
#Path
0/home/anquanhday/cms/public/index.php
1/home/anquanhday/cms/app/Bootstrap.php
2/home/anquanhday/cms/app/config/environment/production.php
3/home/anquanhday/cms/library/modules/Cms/ConfigApp.php
4/home/anquanhday/cms/app/config/global.php
5/home/anquanhday/cms/app/config/modules.php
6/home/anquanhday/cms/library/modules/Application/Loader/Modules.php
7/home/anquanhday/cms/library/config/modules.php
8/home/anquanhday/cms/vendor/autoload.php
9/home/anquanhday/cms/vendor/composer/autoload_real.php
10/home/anquanhday/cms/vendor/composer/ClassLoader.php
11/home/anquanhday/cms/vendor/composer/autoload_static.php
12/home/anquanhday/cms/vendor/symfony/polyfill-mbstring/bootstrap.php
13/home/anquanhday/cms/library/plugins/Options.php
14/home/anquanhday/cms/library/modules/Cms/Model/Configuration.php
15/home/anquanhday/cms/library/modules/Application/Mvc/View/Engine/Volt.php
16/home/anquanhday/cms/library/modules/Application/Widget/Proxy.php
17/home/anquanhday/cms/library/modules/Application/Cache/Manager.php
18/home/anquanhday/cms/library/modules/Application/Acl/DefaultAcl.php
19/home/anquanhday/cms/app/config/acl.php
20/home/anquanhday/cms/library/modules/Application/Assets/Manager.php
21/home/anquanhday/cms/library/modules/Application/Assets/Filter/Less.php
22/home/anquanhday/cms/library/modules/Application/Mvc/Helper.php
23/home/anquanhday/cms/library/modules/MenuBase/Helper/Menu.php
24/home/anquanhday/cms/library/modules/Application/Mvc/Router/DefaultRouter.php
25/home/anquanhday/cms/library/modules/Application/Utils/ModuleName.php
26/home/anquanhday/cms/library/plugins/CheckPoint.php
27/home/anquanhday/cms/library/plugins/Localization.php
28/home/anquanhday/cms/library/modules/Application/Mvc/Helper/CmsCache.php
29/home/anquanhday/cms/library/modules/Cms/Model/Translate.php
30/home/anquanhday/cms/library/plugins/AdminLocalization.php
31/home/anquanhday/cms/data/translations/admin/en.php
32/home/anquanhday/cms/library/plugins/Acl.php
33/home/anquanhday/cms/library/plugins/MobileDetect.php
34/home/anquanhday/cms/vendor/mobiledetect/mobiledetectlib/Mobile_Detect.php
Memory
Usage2097152