#0 | PDO->__construct(mysql:host=localhost;dbname=tla;charset=utf8, root, matkhaudedoan, Array([3] => 2)) |
#1 | Phalcon\Db\Adapter\Pdo->connect(Array([host] => localhost, [username] => root, [password] => matkhaudedoan, [dbname] => tla, [charset] => utf8)) |
#2 | Phalcon\Db\Adapter\Pdo->__construct(Array([host] => localhost, [username] => root, [password] => matkhaudedoan, [dbname] => tla, [charset] => utf8)) /var/www/sites/doctorscar/public/zohoverify/tla/config/bootstrap.php (473) <?php namespace Blazy; use Blazy\Library\Mvc\Url as UrlResolver; use Blazy\Library\Mvc\View\PhpFunctionExtension; use Intervention\Image\ImageManager; use Lamvh\Phalcon\Translate\Translate; use Phalcon\Assets\Manager as AssetsManager; use Phalcon\Cache\BackendInterface; use Phalcon\Cache\Frontend\Output as FrontOutput; use Phalcon\Config; use Phalcon\Di; use Phalcon\DiInterface; use Phalcon\Events\Event; use Phalcon\Events\Manager as EventsManager; use Phalcon\Flash\Direct as Flash; use Phalcon\Flash\Session as FlashSession; use Phalcon\Http\Response\Cookies; use Phalcon\Loader; use Phalcon\Logger\Adapter\File as FileLogger; use Phalcon\Logger\AdapterInterface as LoggerInterface; use Phalcon\Logger\Formatter\Line as FormatterLine; use Phalcon\Mvc\Application; use Phalcon\Mvc\Dispatcher; use Phalcon\Mvc\Model\Manager as ModelsManager; use Phalcon\Mvc\Router; use Phalcon\Mvc\View; use Phalcon\Mvc\View\Exception as ViewException; use Phalcon\Mvc\View\Simple as SimpleView; use Phalcon\Queue\Beanstalk; use Phalcon\Utils\Slug; use RuntimeException; class Bootstrap extends Application { private $app; private $loaders = [ 'cache', 'session', 'view', 'database', 'router', 'url', 'dispatcher', 'flash', 'timezones', 'assets', 'cookie', 'translate', 'media', ]; private $activeModules = ['frontend', 'backend', 'skeleton', 'auth', 'category', 'widget', 'mobile', 'article', 'shop']; /** * Bootstrap constructor. * * @param DiInterface $di */ public function __construct(DiInterface $di) { $em = new EventsManager; $em->enablePriorities(true); $config = $this->initConfig(); // Register the configuration itself as a service $di->setShared('eventsManager', $em); $this->app = new Application; $this->initLogger($di, $config, $em); $this->registerActiveModules($this->activeModules); $this->initLoader($di, $config, $em); foreach ($this->loaders as $service) { $serviceName = ucfirst($service); $this->{'init' . $serviceName}($di, $config, $em); } $this->initBackground(); $this->setEventsManager($em); $this->setDI($di); } /** * Runs the Application * * @return $this|string */ public function run() { if (ENV_TESTING === APPLICATION_ENV) { return $this; } return $this->getOutput(); } /** * Get application output. * * @return string */ public function getOutput() { if ($this instanceof Application) { /** * @var BackendInterface $viewCache */ if (!empty($this->config->viewCache->cacheHtml)) { $viewCache = $this->viewCache; $prefix = $this->config->viewCache->htmlPrefix; $key = $prefix . Slug::generate($this->router->getRewriteUri(), '_'); $output = $viewCache->get($key); if (empty($output)) { $output = $this->handle()->getContent(); $isMinify = false; if (!empty($this->config->minify->mode)) { if (empty($this->config->minify->condition)) { $isMinify = true; } else { $strCondition = $this->dispatcher->getModuleName() . '_' . $this->dispatcher->getControllerName() . '_' . $this->dispatcher->getActionName(); if (stripos($strCondition, $this->config->minify->condition) !== false) { $isMinify = true; } } } if (!empty($isMinify)) { $output = preg_replace('/<!--(.|\s)*?-->/', '', $output); $search = [ '/\>[^\S ]+/s', //strip whitespaces after tags, except space '/[^\S ]+\</s', //strip whitespaces before tags, except space '/(\s)+/s', // shorten multiple whitespace sequences '/>(\s)+</', '/\n/', '/\r/', '/\t/', ]; $replace = [ '>', '<', '\\1', '><', '', '', '', ]; $output = preg_replace($search, $replace, $output); } $viewCache->save($key, $output); } } else { $output = $this->handle()->getContent(); } return $output; } return $this->handle(); } /** * Initialize the Logger. * * @param DiInterface $di Dependency Injector * @param Config $config App config * @param EventsManager $em Events Manager * * @return void */ protected function initLogger(DiInterface $di, Config $config, EventsManager $em) { $di->set('logger', function ($filename = null, $format = null) use ($config) { $format = $format ?: $config->get('logger')->format; $filename = trim($filename ?: $config->get('logger')->filename, '\\/'); $path = rtrim($config->get('logger')->path, '\\/') . DIRECTORY_SEPARATOR; $formatter = new FormatterLine($format, $config->get('logger')->date); $logger = new FileLogger($path . $filename); $logger->setFormatter($formatter); $logger->setLogLevel($config->get('logger')->logLevel); return $logger; }); } /** * Initialize the Loader. * * Adds all required namespaces. * * @param DiInterface $di Dependency Injector * @param Config $config App config * @param EventsManager $em Events Manager * * @return Loader */ protected function initLoader(DiInterface $di, Config $config, EventsManager $em) { $loader = new Loader; $loader->registerNamespaces( [ 'Blazy\Library' => $config->get('application')->libraryDir, 'Blazy\Helper' => $config->get('application')->helpersDir, 'Blazy\Models' => $config->get('application')->modelsDir, 'Blazy\Plugin' => $config->get('application')->pluginsDir, 'Blazy\Constant' => $config->get('application')->constantDir, //module 'Blazy\Library\Mvc' => $config->get('application')->libraryDir . '/mvc/', 'Blazy\Library\Mvc\View' => $config->get('application')->libraryDir . '/mvc/view', 'Blazy\Util' => $config->get('application')->utilModuleDir, ] ); $loader->setEventsManager($em); $loader->register(); $di->setShared('loader', $loader); return $loader; } /** * Initialize the Cache. * * The frontend must always be Phalcon\Cache\Frontend\Output and the service 'viewCache' * must be registered as always open (not shared) in the services container (DI). * * @param DiInterface $di Dependency Injector * @param Config $config App config * @param EventsManager $em Events Manager * * @return void */ protected function initCache(DiInterface $di, Config $config, EventsManager $em) { $di->set('viewCache', function () use ($config) { $frontend = new FrontOutput(['lifetime' => $config->get('viewCache')->lifetime]); $config = $config->get('viewCache')->toArray(); $backend = '\Phalcon\Cache\Backend\\' . $config['backend']; unset($config['backend'], $config['lifetime']); return new $backend($frontend, $config); }); $di->setShared('modelsCache', function () use ($config) { $frontend = '\Phalcon\Cache\Frontend\\' . $config->get('modelsCache')->frontend; $frontend = new $frontend(['lifetime' => $config->get('modelsCache')->lifetime]); $config = $config->get('modelsCache')->toArray(); $backend = '\Phalcon\Cache\Backend\\' . $config['backend']; unset($config['backend'], $config['lifetime'], $config['frontend'], $config['useCache'], $config['isFresh']); return new $backend($frontend, $config); }); $di->setShared('dataCache', function () use ($config) { $frontend = '\Phalcon\Cache\Frontend\\' . $config->get('dataCache')->frontend; $frontend = new $frontend(['lifetime' => $config->get('dataCache')->lifetime]); $config = $config->get('dataCache')->toArray(); $backend = '\Phalcon\Cache\Backend\\' . $config['backend']; unset($config['backend'], $config['lifetime'], $config['frontend'], $config['useCache'], $config['isFresh']); return new $backend($frontend, $config); }); } /** * Initialize the Session Service. * * Start the session the first time some component request the session service. * * @param DiInterface $di Dependency Injector * @param Config $config App config * @param EventsManager $em Events Manager * * @return void */ protected function initSession(DiInterface $di, Config $config, EventsManager $em) { $di->setShared('session', function () use ($config) { $adapter = '\Phalcon\Session\Adapter\\' . $config->get('session')->adapter; /** @var \Phalcon\Session\AdapterInterface $session */ $session = new $adapter; $session->start(); return $session; }); } /** * Initialize the View. * * Setting up the view component. * * * @param DiInterface $di Dependency Injector * @param Config $config App config * @param EventsManager $em Events Manager * * @return Loader */ protected function initView(DiInterface $di, Config $config, EventsManager $em) { $di->setShared('view', function () use ($di, $config, $em) { $view = new View; $view->registerEngines([ // Setting up Volt Engine '.volt' => function ($view, $di) use ($config) { $volt = new \Phalcon\Mvc\View\Engine\Volt($view, $di); $voltConfig = $config->get('volt')->toArray(); $options = [ 'compiledPath' => $voltConfig['cacheDir'], 'compiledExtension' => $voltConfig['compiledExt'], 'compiledSeparator' => $voltConfig['separator'], 'compileAlways' => ENV_DEVELOPMENT === APPLICATION_ENV && $voltConfig['forceCompile'], ]; $volt->setOptions($options); $compiler = $volt->getCompiler(); $compiler->addExtension(new PhpFunctionExtension()); $compiler->addFunction('number_format', function ($resolvedArgs) { return 'number_format(' . $resolvedArgs . ')'; }); $compiler->addFunction('truncate', 'Lamvh\Phalcon\Utils\Str::truncateSafe'); $compiler->addFunction('in_array', 'in_array'); $compiler->addFunction('blockRender', function ($resolvedArgs, $exprArgs) { return sprintf('$this->block->render(%s)', $resolvedArgs); }); $compiler->addFunction( 'repeat', function ($resolvedArgs, $exprArgs) use ($compiler) { // Resolve the first argument $firstArgument = $compiler->expression($exprArgs[0]['expr']); // Checks if the second argument was passed if (isset($exprArgs[1])) { $secondArgument = $compiler->expression($exprArgs[1]['expr']); } else { // Use '10' as default $secondArgument = '10'; } return 'str_repeat(' . $firstArgument . ', ' . $secondArgument . ')'; } ); return $volt; }, ]); $view->setViewsDir($config->get('application')->viewsDir); $em->attach('view', function ($event, $view) use ($di, $config) { /** * @var LoggerInterface $logger * @var View $view * @var Event $event * @var DiInterface $di */ $logger = $di->get('logger'); $logger->debug(sprintf('Event %s. Path: %s', $event->getType(), $view->getActiveRenderPath())); if ('notFoundView' == $event->getType()) { $message = sprintf('View not found: %s', $view->getActiveRenderPath()); $logger->error($message); throw new ViewException($message); } }); $view->setEventsManager($em); return $view; }); $di->setShared('simpleView', function () use ($di, $config, $em) { $simpleView = new SimpleView(); $simpleView->registerEngines([ // Setting up Volt Engine '.volt' => function ($view, $di) use ($config) { $volt = new \Phalcon\Mvc\View\Engine\Volt($view, $di); $voltConfig = $config->get('volt')->toArray(); $options = [ 'compiledPath' => $voltConfig['cacheDir'], 'compiledExtension' => $voltConfig['compiledExt'], 'compiledSeparator' => $voltConfig['separator'], 'compileAlways' => ENV_DEVELOPMENT === APPLICATION_ENV && $voltConfig['forceCompile'], ]; $volt->setOptions($options); $compiler = $volt->getCompiler(); $compiler->addFunction('number_format', function ($resolvedArgs) { return 'number_format(' . $resolvedArgs . ')'; }); return $volt; }, // Setting up Php Engine '.phtml' => 'Phalcon\Mvc\View\Engine\Php', ]); $simpleView->setViewsDir($config->get('application')->viewsDir); $em->attach('simpleView', function ($event, $view) use ($di, $config) { /** * @var LoggerInterface $logger * @var View $view * @var Event $event * @var DiInterface $di */ $logger = $di->get('logger'); $logger->debug(sprintf('Event %s. Path: %s', $event->getType(), $view->getActiveRenderPath())); if ('notFoundView' == $event->getType()) { $message = sprintf('View not found: %s', $view->getActiveRenderPath()); $logger->error($message); throw new ViewException($message); } }); $simpleView->setEventsManager($em); return $simpleView; }); } /** * Initialize the Database connection. * * Database connection is created based in the parameters defined in the configuration file. * * @param DiInterface $di Dependency Injector * @param Config $config App config * @param EventsManager $em Events Manager * * @return void */ protected function initDatabase(DiInterface $di, Config $config, EventsManager $em) { $di->setShared('db', function () use ($config, $em, $di) { $config = $config->database->toArray(); $adapter = '\Phalcon\Db\Adapter\Pdo\\' . $config['adapter']; unset($config['adapter']); /** @var \Phalcon\Db\Adapter\Pdo $connection */ $connection = new $adapter($config); // Listen all the database events $em->attach( 'db', function ($event, $connection) use ($di) { /** * @var \Phalcon\Events\Event $event * @var \Phalcon\Db\AdapterInterface $connection * @var \Phalcon\DiInterface $di */ if ($event->getType() == 'beforeQuery') { $variables = $connection->getSQLVariables(); $string = $connection->getSQLStatement(); if ($variables) { $string .= "\n" . print_r($variables, true);; } // To disable logging change logLevel in config $di->get('logger', ['db.log'])->debug($string); } } ); // Assign the eventsManager to the db adapter instance $connection->setEventsManager($em); return $connection; }); $di->setShared('modelsManager', function () use ($em) { $modelsManager = new ModelsManager; $modelsManager->setEventsManager($em); return $modelsManager; }); $di->setShared('modelsMetadata', function () use ($config, $em) { $config = $config->get('metadata')->toArray(); $adapter = '\Phalcon\Mvc\Model\Metadata\\' . $config['adapter']; unset($config['adapter']); $metaData = new $adapter($config); return $metaData; }); } /** * Initialize the Queue Service. * TODO: Not yet implement * * Queue to deliver e-mails in real-time and other tasks. * * @param DiInterface $di Dependency Injector * @param Config $config App config * @param EventsManager $em Events Manager * * @return void */ protected function initQueue(DiInterface $di, Config $config, EventsManager $em) { $di->setShared('queue', function () use ($config) { $config = $config->get('beanstalk'); $config->get('disabled', true); if ($config->get('disabled', true)) { return new DummyServer(); } if (!$host = $config->get('host', false)) { $error = 'Beanstalk is not configured'; if (class_exists('\Phalcon\Queue\Beanstalk\Exception')) { $exception = '\Phalcon\Queue\Beanstalk\Exception'; } else { $exception = '\Phalcon\Exception'; } throw new $exception($error); } return new Beanstalk(['host' => $host]); }); } /** * Initialize the Router. * * @param DiInterface $di Dependency Injector * @param Config $config App config * @param EventsManager $em Events Manager * * @return void */ protected function initRouter(DiInterface $di, Config $config, EventsManager $em) { $di->setShared('router', function () use ($config, $em) { /** @var \Phalcon\Mvc\Router $router */ $router = include BASE_DIR . 'config/routes.php'; if (!isset($_GET['_url'])) { $router->setUriSource(Router::URI_SOURCE_SERVER_REQUEST_URI); } if (preg_match('/(.jpg|.jpge|.png|.gif|.ico|.css|.js)$/', $router->getRewriteUri())) { exit; } $router->removeExtraSlashes(true); $router->setEventsManager($em); $router->setDefaultNamespace('Blazy\Frontend\Controllers'); $router->setDefaultModule('frontend'); $router->notFound(['controller' => 'error', 'action' => 'route404']); return $router; }); } /** * Initialize the Url service. * * The URL component is used to generate all kind of urls in the application. * * @param DiInterface $di Dependency Injector * @param Config $config App config * @param EventsManager $em Events Manager * * @return void */ protected function initUrl(DiInterface $di, Config $config, EventsManager $em) { $di->setShared('url', function () use ($config) { $url = new UrlResolver; $url->setBaseUri($config->application->baseUri); $url->setStaticBaseUri(STATIC_BASE_URL . $config->application->baseUri); return $url; }); } /** * Initialize the Dispatcher. * * @param DiInterface $di Dependency Injector * @param Config $config App config * @param EventsManager $em Events Manager * * @return void */ protected function initDispatcher(DiInterface $di, Config $config, EventsManager $em) { $di->setShared('dispatcher', function () use ($em) { $dispatcher = new Dispatcher; $dispatcher->setDefaultNamespace('Blazy\Frontend\Controllers'); $em->attach('dispatch:beforeException', function ($event, $dispatcher, $exception) { if (!class_exists('Blazy\Backend\Module')) { include_once BASE_DIR . '/app/modules/backend/module.php'; $module = new Backend\Module(); $module->registerServices($this->getDI()); $module->registerAutoloaders($this->getDI()); $dispatcher->setNamespaceName('Blazy\Backend\Controllers'); } }); $dispatcher->setEventsManager($em); return $dispatcher; }); } /** * Initialize the Flash Service. * * Register the Flash Service with the Twitter Bootstrap classes * * @param DiInterface $di Dependency Injector * @param Config $config App config * @param EventsManager $em Events Manager * * @return void */ protected function initFlash(DiInterface $di, Config $config, EventsManager $em) { $di->setShared('flash', function () { $flash = new Flash( [ 'error' => 'alert alert-danger fade in', 'success' => 'alert alert-success fade in', 'notice' => 'alert alert-info fade in', 'warning' => 'alert alert-warning fade in', ] ); return $flash; }); $di->setShared('flashInline', function () use ($di) { $flash = $di->getShared('flash'); $flash->setCssClasses([ 'error' => 'custom-message error', 'success' => 'alert alert-success fade in', 'notice' => 'alert alert-info fade in', 'warning' => 'alert alert-warning fade in', ]); return $flash; }); $di->setShared( 'flashSession', function () { return new FlashSession([ 'error' => 'alert alert-danger fade in', 'success' => 'alert alert-success fade in alert-hightlight', 'notice' => 'alert alert-info fade in', 'warning' => 'alert alert-warning fade in', ]); } ); } /** * Initialize time zones. * * @param DiInterface $di Dependency Injector * @param Config $config App config * @param EventsManager $em Events Manager * * @return void */ protected function initTimezones(DiInterface $di, Config $config, EventsManager $em) { $di->setShared('timezones', function () use ($config) { return require_once BASE_DIR . 'config/timezones.php'; }); } /** * Load module's configuration file, prepare and return the Config. * * @param string $path Config path [Optional] * * @return Config * @throws RuntimeException */ protected function initConfig($path = null) { $path = $path ?: BASE_DIR . 'config/'; if (!is_readable($path . 'config.php')) { throw new RuntimeException( 'Unable to read config from ' . $path . 'config.php' ); } $di = Di::getDefault(); /** * Load default configuration and run module background job * * @var \Phalcon\Config $config */ $config = include_once $path . 'config.php'; $di->setShared('config', $config); foreach ($this->activeModules as $module) { if (is_readable(BASE_DIR . 'app/modules/' . $module . '/config.php')) $config->offsetSet($module, include_once BASE_DIR . 'app/modules/' . $module . '/config.php'); } /** * Load environment configuration * * @var \Phalcon\Config $envConfig */ $envConfig = include_once $path . 'config.' . APPLICATION_ENV . '.php'; foreach ($this->activeModules as $module) { if (is_readable(BASE_DIR . 'app/modules/' . $module . '/config.' . APPLICATION_ENV . '.php')) $envConfig->offsetSet($module, include_once BASE_DIR . 'app/modules/' . $module . '/config.' . APPLICATION_ENV . '.php'); } if ($envConfig instanceof Config) { $config->merge($envConfig); } return $config; } protected function initBackground() { $di = Di::getDefault(); foreach ($this->activeModules as $module) { if (is_readable(BASE_DIR . 'app/modules/' . $module . '/Background.php')) { include_once BASE_DIR . 'app/modules/' . $module . '/Background.php'; $background = 'Blazy\\' . $module . '\Background'; new $background($di); } } } /** * @param DiInterface $di * @param Config $config * @param EventsManager $em */ protected function initAssets(DiInterface $di, Config $config, EventsManager $em) { $di->setShared('assets', function () use ($config, $em) { return new AssetsManager(); }); } /*protected function initViewSimple(DiInterface $di, Config $config, EventsManager $em) { $di->setShared('viewSimple', function() { $view = new ViewSimple(); $view->setViewsDir($config->application->viewsDir); return new ViewSimple(); }); }*/ /** * starts the cookie the first time some component requests the cookie service * * @param DiInterface $di * @param Config $config * @param EventsManager $em */ protected function initCookie(DiInterface $di, Config $config, EventsManager $em) { $di->setShared('cookies', function () { $cookies = new Cookies(); $cookies->useEncryption(false); return $cookies; }); } /** * Multi language * * @param DiInterface $di * @param Config $config * @param EventsManager $em */ protected function initTranslate(DiInterface $di, Config $config, EventsManager $em) { $di->setShared('translate', function () use ($di, $config) { $translate = new Translate($config->application->messagesDir, $config->application->defaultLanguage); $dispatcher = $di->getShared('dispatcher'); $lang = $dispatcher->getParam('lang'); if (!empty($lang)) { $translate->setCurrentLanguage($lang); } return $translate; }); $di->setShared('t', function () use ($di, $config) { return $di->getShared('translate')->getTranslation(); }); } /** * media manager: image, video .. * * @param DiInterface $di * @param Config $config * @param EventsManager $em */ protected function initMedia(DiInterface $di, Config $config, EventsManager $em) { $di->setShared('image', new ImageManager(['driver' => 'gd'])); } public function registerActiveModules($modules, $merge = false) { $preparedModules = []; foreach ($modules as $module) { $preparedModules[$module] = [ 'className' => 'Blazy\\' . ucfirst($module) . '\\Module', 'path' => BASE_DIR . 'app/modules/' . $module . '/Module.php', ]; } parent::registerModules($preparedModules, $merge); } } |
#3 | Blazy\Bootstrap->Blazy\{closure}() |
#4 | Phalcon\Di\Service->resolve(null, Object(Phalcon\Di\FactoryDefault)) |
#5 | Phalcon\Di->get(db, null) |
#6 | Phalcon\Di->getShared(db) |
#7 | Phalcon\Mvc\Model\Manager->_getConnection(Object(Lamvh\Phalcon\Auth\Models\Role: [role_id] => null, [role_name] => null, [role_description] => null, [role_status] => null), null) |
#8 | Phalcon\Mvc\Model\Manager->getReadConnection(Object(Lamvh\Phalcon\Auth\Models\Role: [role_id] => null, [role_name] => null, [role_description] => null, [role_status] => null)) |
#9 | Phalcon\Mvc\Model->getReadConnection() |
#10 | Phalcon\Mvc\Model\Query->_executeSelect(Array([models] => Array([0] => Lamvh\Phalcon\Auth\Models\Role), [tables] => Array([0] => role), [columns] => Array([lamvh\Phalcon\Auth\Models\Role] => Array([type] => object, [model] => Lamvh\Phalcon\Auth\Models\Role, [column] => role, [balias] => lamvh\Phalcon\Auth\Models\Role)), [limit] => Array([number] => Array([type] => placeholder, [value] => :APL0))), Array([APL0] => 1), Array([APL0] => 1)) |
#11 | Phalcon\Mvc\Model\Query->execute() |
#12 | Phalcon\Mvc\Model::findFirst(null) /var/www/sites/doctorscar/public/zohoverify/tla/vendor/lamvh/phalcon/src/mvc/models/CacheableModel.php (143) <?php namespace Lamvh\Phalcon\Mvc\Models; use Lamvh\Phalcon\Mvc\Controllers\CacheableController; use Phalcon\DI; use Phalcon\Mvc\Model; /** * Class CacheableModel * * @package Bcore\Models */ class CacheableModel extends Model { protected static $_cache = []; /** * Implement a method that returns a string key based * on the query parameters */ protected static function _createKey($parameters) { $uniqueKey = []; foreach ($parameters as $key => $value) { if (is_scalar($value)) { $uniqueKey[] = $key . '_' . $value; } else { if (is_array($value)) { $uniqueKey[] = $key . ':[' . self::_createKey($value) . ']'; } } } $uniqueString = join(',', $uniqueKey); return md5($uniqueString); } public static function find($parameters = null) { $config = DI::getDefault()->getShared('config'); if (empty($config->modelsCache->useCache)) { return parent::find($parameters); } // Convert the parameters to an array if (!is_array($parameters)) { $parameters = [$parameters]; } // Check if a cache key wasn't passed // and create the cache parameters if (!isset($parameters['cache'])) { $createKey = preg_replace('/[^0-9A-Za-z]/', '_', get_called_class() . '-find-' . self::_createKey($parameters)); $parameters['cache'] = [ 'key' => $createKey, ]; } return parent::find($parameters); } /** * @param null $parameters * * @return mixed */ public static function maximum($parameters = null) { $config = DI::getDefault()->getShared('config'); if (empty($config->modelsCache->useCache)) { return parent::maximum($parameters); } // Convert the parameters to an array if (!is_array($parameters)) { $parameters = [$parameters]; } // Check if a cache key wasn't passed // and create the cache parameters if (!isset($parameters['cache'])) { $createKey = preg_replace('/[^0-9A-Za-z]/', '_', get_called_class() . '-maximum-' . self::_createKey($parameters)); $parameters['cache'] = [ 'key' => $createKey, ]; } return parent::maximum($parameters); } public static function count($parameters = null) { $config = DI::getDefault()->getShared('config'); if (empty($config->modelsCache->useCache)) { return parent::count($parameters); } // Convert the parameters to an array if (!is_array($parameters)) { $parameters = [$parameters]; } // Check if a cache key wasn't passed // and create the cache parameters if (!isset($parameters['cache'])) { $createKey = preg_replace('/[^0-9A-Za-z]/', '_', get_called_class() . '-count-' . self::_createKey($parameters)); $parameters['cache'] = [ 'key' => $createKey, ]; } return parent::count($parameters); } /** * Caches models data in memory * * @param null $parameters * * @return Model */ public static function findFirst($parameters = null) { $config = DI::getDefault()->getShared('config'); if (empty($config->modelsCache->useCache)) { return parent::findFirst($parameters); } // Convert the parameters to an array if (!is_array($parameters)) { $parameters = [$parameters]; } // Check if a cache key wasn't passed // and create the cache parameters if (!isset($parameters['cache'])) { $createKey = preg_replace('/[^0-9A-Za-z]/', '_', get_called_class() . '-find-first-' . self::_createKey($parameters)); $parameters['cache'] = [ 'key' => $createKey, ]; } return parent::findFirst($parameters); } /** * Allows to use the model as a resultset's row * * @param $value * * @return $this */ public function setIsFresh($value) { return $this; } /** * Allows to use the model as a resultset's row * * @return $this */ public function getFirst() { return $this; } public function afterSave() { //clean cache $this->clearCache(); } public function afterDelete() { //clean cache $this->clearCache(); } /** * Clears the cache related to this post */ public function clearCache() { $config = DI::getDefault()->getShared('config'); if (!empty($config->modelsCache->isFresh)) { $modelCache = $this->getDI()->getShared('modelsCache'); $option = $modelCache->getOptions(); $prefix = $option['prefix']; $queryKeys = $modelCache->queryKeys($prefix . preg_replace('/[^0-9A-Za-z]/', '_', get_called_class())); foreach ($queryKeys as $key) { $key = substr($key, strlen($prefix)); $modelCache->delete($key); } } if (!empty($config->dataCache->isFresh)) { $dataCache = $this->getDI()->getShared('dataCache'); $option = $dataCache->getOptions(); $prefix = $option['prefix']; $queryKeys = $dataCache->queryKeys($prefix . CacheableController::getGroupName(get_called_class())); foreach ($queryKeys as $key) { $key = substr($key, strlen($prefix)); $dataCache->delete($key); } } if (!empty($config->viewCache->isFresh) && !empty($config->viewCache->htmlPrefix)) { $viewCache = $this->getDI()->getShared('viewCache'); $option = $viewCache->getOptions(); $prefix = $option['prefix']; $queryKeys = $viewCache->queryKeys($prefix . $config->viewCache->htmlPrefix . CacheableController::getGroupName(get_called_class())); foreach ($queryKeys as $key) { $key = substr($key, strlen($prefix)); $viewCache->delete($key); } } } } |
#13 | Lamvh\Phalcon\Mvc\Models\CacheableModel::findFirst(null) /var/www/sites/doctorscar/public/zohoverify/tla/vendor/lamvh/phalcon/src/auth/models/Role.php (76) <?php namespace Lamvh\Phalcon\Auth\Models; use Lamvh\Phalcon\Mvc\Models\CacheableModel; class Role extends CacheableModel { /** * * @var integer */ public $role_id; /** * * @var string */ public $role_name; /** * * @var string */ public $role_description; /** * * @var integer */ public $role_status; /** * Initialize method for model. */ public function initialize() { $this->hasMany('role_name', 'Lamvh\Phalcon\Auth\Models\RolePermission', 'role_name', ['alias' => 'RolePermission']); $this->hasMany('role_name', 'Blazy\Auth\Models\UserRole', 'role_name', ['alias' => 'UserRole']); $this->hasMany('role_name', 'Lamvh\Phalcon\Auth\Models\RolePermission', 'role_name', null); $this->hasMany('role_name', 'Blazy\Auth\Models\UserRole', 'role_name', null); } /** * Returns table name mapped in the model. * * @return string */ public function getSource() { return 'role'; } /** * Allows to query a set of records that match the specified conditions * * @param mixed $parameters * * @return Role[] */ public static function find($parameters = null) { return parent::find($parameters); } /** * Allows to query the first record that match the specified conditions * * @param mixed $parameters * * @return Role */ public static function findFirst($parameters = null) { return parent::findFirst($parameters); } /** * Independent Column Mapping. * Keys are the real names in the table and the values their names in the application * * @return array */ public function columnMap() { return [ 'role_id' => 'role_id', 'role_name' => 'role_name', 'role_description' => 'role_description', 'role_status' => 'role_status', ]; } } |
#14 | Lamvh\Phalcon\Auth\Models\Role::findFirst() /var/www/sites/doctorscar/public/zohoverify/tla/app/modules/auth/plugin/Security.php (28) <?php namespace Blazy\Auth\Plugin; use Lamvh\Phalcon\Auth\Library\Authentication; use Lamvh\Phalcon\Auth\Library\Authorization; use Lamvh\Phalcon\Auth\Models\Role; use Phalcon\Di; use Phalcon\Events\Event; use Phalcon\Mvc\Dispatcher; use Phalcon\Mvc\User\Plugin; /** * Class Security * @package Lamvh\Phalcon\Auth\Plugin */ class Security extends Plugin { /** * @param Event $event * @param Dispatcher $dispatcher * * @return bool */ public function beforeDispatch(Event $event, Dispatcher $dispatcher) { if (!empty(Role::findFirst())) { /** * @var Authentication $authentication */ $authentication = $this->authentication; if ($authentication->hasRememberMe() && !$authentication->loggedIn()) { $authentication->loginWithRememberMe('loginByUserName'); } /** * @var Authorization $authorization */ $authorization = $this->authorization; $user = $authentication->currentUser(); $moduleName = $dispatcher->getModuleName(); $controllerName = $dispatcher->getControllerName(); $actionName = $dispatcher->getActionName(); // Get entered language. $language = $this->dispatcher->getParam('lang', null, null); if (!empty($language)) { $this->translate->setCurrentLanguage($language); } if (empty($this->translate->getCurrentLanguage()) && !empty($user['user_language']) && $user['user_language'] != $this->translate->getDefaultLanguage() ) { $uri = $this->request->getURI(); return $this->response->redirect(BASE_URL . '/' . $user['user_language'] . $uri); } if (!$user) { if ($moduleName == 'backend' /*&& (APPLICATION_ENV != ENV_DEVELOPMENT)*/) { return $this->response->redirect( $this->url->get(['for' => 'login_admin']) . '&url=' . $this->router->getRewriteUri()); } else { $role = 'guest'; $allowed = $authorization->isAllowed(['checkByRole' => $role], $moduleName, $controllerName, $actionName); if (($allowed != Authorization::ALLOW) && !($moduleName == 'auth' && $controllerName == 'index') && (APPLICATION_ENV != ENV_STAGING) && !($moduleName == 'shop' && $controllerName == 'index') && !($moduleName == 'frontend' && $controllerName == 'index') && (APPLICATION_ENV != ENV_DEVELOPMENT) && $controllerName != 'ajax' ) { return $this->response->redirect( $this->url->get(['for' => 'login']) . '&url=' . $this->router->getRewriteUri()); } } } else { if (empty($user['role'])) { $role = 'guest'; $allowed = $authorization->isAllowed(['checkByRole' => $role], $moduleName, $controllerName, $actionName); } else { $userRole = $user['role']; $allowed = $authorization->isAllowed( ['checkByRole' => ['arr_role_name' => $userRole], 'checkByUser' => $user['user_id']], $moduleName, $controllerName, $actionName); } } if ($allowed != Authorization::ALLOW && (APPLICATION_ENV != ENV_DEVELOPMENT) && (APPLICATION_ENV != ENV_STAGING) && !($moduleName == 'frontend' && $controllerName == 'error') && !($moduleName == 'auth' && $controllerName == 'index') && !($moduleName == 'shop' && $controllerName == 'index') && $controllerName != 'ajax' ) { $this->response->redirect($this->url->get(['for' => 'permission-deny'])); } } } } |
#15 | Blazy\Auth\Plugin\Security->beforeDispatch(Object(Phalcon\Events\Event), Object(Phalcon\Mvc\Dispatcher), null) |
#16 | Phalcon\Events\Manager->fireQueue(Object(SplPriorityQueue), Object(Phalcon\Events\Event)) |
#17 | Phalcon\Events\Manager->fire(dispatch:beforeDispatch, Object(Phalcon\Mvc\Dispatcher)) |
#18 | Phalcon\Dispatcher->dispatch() |
#19 | Phalcon\Mvc\Application->handle() /var/www/sites/doctorscar/public/zohoverify/tla/config/bootstrap.php (175) <?php namespace Blazy; use Blazy\Library\Mvc\Url as UrlResolver; use Blazy\Library\Mvc\View\PhpFunctionExtension; use Intervention\Image\ImageManager; use Lamvh\Phalcon\Translate\Translate; use Phalcon\Assets\Manager as AssetsManager; use Phalcon\Cache\BackendInterface; use Phalcon\Cache\Frontend\Output as FrontOutput; use Phalcon\Config; use Phalcon\Di; use Phalcon\DiInterface; use Phalcon\Events\Event; use Phalcon\Events\Manager as EventsManager; use Phalcon\Flash\Direct as Flash; use Phalcon\Flash\Session as FlashSession; use Phalcon\Http\Response\Cookies; use Phalcon\Loader; use Phalcon\Logger\Adapter\File as FileLogger; use Phalcon\Logger\AdapterInterface as LoggerInterface; use Phalcon\Logger\Formatter\Line as FormatterLine; use Phalcon\Mvc\Application; use Phalcon\Mvc\Dispatcher; use Phalcon\Mvc\Model\Manager as ModelsManager; use Phalcon\Mvc\Router; use Phalcon\Mvc\View; use Phalcon\Mvc\View\Exception as ViewException; use Phalcon\Mvc\View\Simple as SimpleView; use Phalcon\Queue\Beanstalk; use Phalcon\Utils\Slug; use RuntimeException; class Bootstrap extends Application { private $app; private $loaders = [ 'cache', 'session', 'view', 'database', 'router', 'url', 'dispatcher', 'flash', 'timezones', 'assets', 'cookie', 'translate', 'media', ]; private $activeModules = ['frontend', 'backend', 'skeleton', 'auth', 'category', 'widget', 'mobile', 'article', 'shop']; /** * Bootstrap constructor. * * @param DiInterface $di */ public function __construct(DiInterface $di) { $em = new EventsManager; $em->enablePriorities(true); $config = $this->initConfig(); // Register the configuration itself as a service $di->setShared('eventsManager', $em); $this->app = new Application; $this->initLogger($di, $config, $em); $this->registerActiveModules($this->activeModules); $this->initLoader($di, $config, $em); foreach ($this->loaders as $service) { $serviceName = ucfirst($service); $this->{'init' . $serviceName}($di, $config, $em); } $this->initBackground(); $this->setEventsManager($em); $this->setDI($di); } /** * Runs the Application * * @return $this|string */ public function run() { if (ENV_TESTING === APPLICATION_ENV) { return $this; } return $this->getOutput(); } /** * Get application output. * * @return string */ public function getOutput() { if ($this instanceof Application) { /** * @var BackendInterface $viewCache */ if (!empty($this->config->viewCache->cacheHtml)) { $viewCache = $this->viewCache; $prefix = $this->config->viewCache->htmlPrefix; $key = $prefix . Slug::generate($this->router->getRewriteUri(), '_'); $output = $viewCache->get($key); if (empty($output)) { $output = $this->handle()->getContent(); $isMinify = false; if (!empty($this->config->minify->mode)) { if (empty($this->config->minify->condition)) { $isMinify = true; } else { $strCondition = $this->dispatcher->getModuleName() . '_' . $this->dispatcher->getControllerName() . '_' . $this->dispatcher->getActionName(); if (stripos($strCondition, $this->config->minify->condition) !== false) { $isMinify = true; } } } if (!empty($isMinify)) { $output = preg_replace('/<!--(.|\s)*?-->/', '', $output); $search = [ '/\>[^\S ]+/s', //strip whitespaces after tags, except space '/[^\S ]+\</s', //strip whitespaces before tags, except space '/(\s)+/s', // shorten multiple whitespace sequences '/>(\s)+</', '/\n/', '/\r/', '/\t/', ]; $replace = [ '>', '<', '\\1', '><', '', '', '', ]; $output = preg_replace($search, $replace, $output); } $viewCache->save($key, $output); } } else { $output = $this->handle()->getContent(); } return $output; } return $this->handle(); } /** * Initialize the Logger. * * @param DiInterface $di Dependency Injector * @param Config $config App config * @param EventsManager $em Events Manager * * @return void */ protected function initLogger(DiInterface $di, Config $config, EventsManager $em) { $di->set('logger', function ($filename = null, $format = null) use ($config) { $format = $format ?: $config->get('logger')->format; $filename = trim($filename ?: $config->get('logger')->filename, '\\/'); $path = rtrim($config->get('logger')->path, '\\/') . DIRECTORY_SEPARATOR; $formatter = new FormatterLine($format, $config->get('logger')->date); $logger = new FileLogger($path . $filename); $logger->setFormatter($formatter); $logger->setLogLevel($config->get('logger')->logLevel); return $logger; }); } /** * Initialize the Loader. * * Adds all required namespaces. * * @param DiInterface $di Dependency Injector * @param Config $config App config * @param EventsManager $em Events Manager * * @return Loader */ protected function initLoader(DiInterface $di, Config $config, EventsManager $em) { $loader = new Loader; $loader->registerNamespaces( [ 'Blazy\Library' => $config->get('application')->libraryDir, 'Blazy\Helper' => $config->get('application')->helpersDir, 'Blazy\Models' => $config->get('application')->modelsDir, 'Blazy\Plugin' => $config->get('application')->pluginsDir, 'Blazy\Constant' => $config->get('application')->constantDir, //module 'Blazy\Library\Mvc' => $config->get('application')->libraryDir . '/mvc/', 'Blazy\Library\Mvc\View' => $config->get('application')->libraryDir . '/mvc/view', 'Blazy\Util' => $config->get('application')->utilModuleDir, ] ); $loader->setEventsManager($em); $loader->register(); $di->setShared('loader', $loader); return $loader; } /** * Initialize the Cache. * * The frontend must always be Phalcon\Cache\Frontend\Output and the service 'viewCache' * must be registered as always open (not shared) in the services container (DI). * * @param DiInterface $di Dependency Injector * @param Config $config App config * @param EventsManager $em Events Manager * * @return void */ protected function initCache(DiInterface $di, Config $config, EventsManager $em) { $di->set('viewCache', function () use ($config) { $frontend = new FrontOutput(['lifetime' => $config->get('viewCache')->lifetime]); $config = $config->get('viewCache')->toArray(); $backend = '\Phalcon\Cache\Backend\\' . $config['backend']; unset($config['backend'], $config['lifetime']); return new $backend($frontend, $config); }); $di->setShared('modelsCache', function () use ($config) { $frontend = '\Phalcon\Cache\Frontend\\' . $config->get('modelsCache')->frontend; $frontend = new $frontend(['lifetime' => $config->get('modelsCache')->lifetime]); $config = $config->get('modelsCache')->toArray(); $backend = '\Phalcon\Cache\Backend\\' . $config['backend']; unset($config['backend'], $config['lifetime'], $config['frontend'], $config['useCache'], $config['isFresh']); return new $backend($frontend, $config); }); $di->setShared('dataCache', function () use ($config) { $frontend = '\Phalcon\Cache\Frontend\\' . $config->get('dataCache')->frontend; $frontend = new $frontend(['lifetime' => $config->get('dataCache')->lifetime]); $config = $config->get('dataCache')->toArray(); $backend = '\Phalcon\Cache\Backend\\' . $config['backend']; unset($config['backend'], $config['lifetime'], $config['frontend'], $config['useCache'], $config['isFresh']); return new $backend($frontend, $config); }); } /** * Initialize the Session Service. * * Start the session the first time some component request the session service. * * @param DiInterface $di Dependency Injector * @param Config $config App config * @param EventsManager $em Events Manager * * @return void */ protected function initSession(DiInterface $di, Config $config, EventsManager $em) { $di->setShared('session', function () use ($config) { $adapter = '\Phalcon\Session\Adapter\\' . $config->get('session')->adapter; /** @var \Phalcon\Session\AdapterInterface $session */ $session = new $adapter; $session->start(); return $session; }); } /** * Initialize the View. * * Setting up the view component. * * * @param DiInterface $di Dependency Injector * @param Config $config App config * @param EventsManager $em Events Manager * * @return Loader */ protected function initView(DiInterface $di, Config $config, EventsManager $em) { $di->setShared('view', function () use ($di, $config, $em) { $view = new View; $view->registerEngines([ // Setting up Volt Engine '.volt' => function ($view, $di) use ($config) { $volt = new \Phalcon\Mvc\View\Engine\Volt($view, $di); $voltConfig = $config->get('volt')->toArray(); $options = [ 'compiledPath' => $voltConfig['cacheDir'], 'compiledExtension' => $voltConfig['compiledExt'], 'compiledSeparator' => $voltConfig['separator'], 'compileAlways' => ENV_DEVELOPMENT === APPLICATION_ENV && $voltConfig['forceCompile'], ]; $volt->setOptions($options); $compiler = $volt->getCompiler(); $compiler->addExtension(new PhpFunctionExtension()); $compiler->addFunction('number_format', function ($resolvedArgs) { return 'number_format(' . $resolvedArgs . ')'; }); $compiler->addFunction('truncate', 'Lamvh\Phalcon\Utils\Str::truncateSafe'); $compiler->addFunction('in_array', 'in_array'); $compiler->addFunction('blockRender', function ($resolvedArgs, $exprArgs) { return sprintf('$this->block->render(%s)', $resolvedArgs); }); $compiler->addFunction( 'repeat', function ($resolvedArgs, $exprArgs) use ($compiler) { // Resolve the first argument $firstArgument = $compiler->expression($exprArgs[0]['expr']); // Checks if the second argument was passed if (isset($exprArgs[1])) { $secondArgument = $compiler->expression($exprArgs[1]['expr']); } else { // Use '10' as default $secondArgument = '10'; } return 'str_repeat(' . $firstArgument . ', ' . $secondArgument . ')'; } ); return $volt; }, ]); $view->setViewsDir($config->get('application')->viewsDir); $em->attach('view', function ($event, $view) use ($di, $config) { /** * @var LoggerInterface $logger * @var View $view * @var Event $event * @var DiInterface $di */ $logger = $di->get('logger'); $logger->debug(sprintf('Event %s. Path: %s', $event->getType(), $view->getActiveRenderPath())); if ('notFoundView' == $event->getType()) { $message = sprintf('View not found: %s', $view->getActiveRenderPath()); $logger->error($message); throw new ViewException($message); } }); $view->setEventsManager($em); return $view; }); $di->setShared('simpleView', function () use ($di, $config, $em) { $simpleView = new SimpleView(); $simpleView->registerEngines([ // Setting up Volt Engine '.volt' => function ($view, $di) use ($config) { $volt = new \Phalcon\Mvc\View\Engine\Volt($view, $di); $voltConfig = $config->get('volt')->toArray(); $options = [ 'compiledPath' => $voltConfig['cacheDir'], 'compiledExtension' => $voltConfig['compiledExt'], 'compiledSeparator' => $voltConfig['separator'], 'compileAlways' => ENV_DEVELOPMENT === APPLICATION_ENV && $voltConfig['forceCompile'], ]; $volt->setOptions($options); $compiler = $volt->getCompiler(); $compiler->addFunction('number_format', function ($resolvedArgs) { return 'number_format(' . $resolvedArgs . ')'; }); return $volt; }, // Setting up Php Engine '.phtml' => 'Phalcon\Mvc\View\Engine\Php', ]); $simpleView->setViewsDir($config->get('application')->viewsDir); $em->attach('simpleView', function ($event, $view) use ($di, $config) { /** * @var LoggerInterface $logger * @var View $view * @var Event $event * @var DiInterface $di */ $logger = $di->get('logger'); $logger->debug(sprintf('Event %s. Path: %s', $event->getType(), $view->getActiveRenderPath())); if ('notFoundView' == $event->getType()) { $message = sprintf('View not found: %s', $view->getActiveRenderPath()); $logger->error($message); throw new ViewException($message); } }); $simpleView->setEventsManager($em); return $simpleView; }); } /** * Initialize the Database connection. * * Database connection is created based in the parameters defined in the configuration file. * * @param DiInterface $di Dependency Injector * @param Config $config App config * @param EventsManager $em Events Manager * * @return void */ protected function initDatabase(DiInterface $di, Config $config, EventsManager $em) { $di->setShared('db', function () use ($config, $em, $di) { $config = $config->database->toArray(); $adapter = '\Phalcon\Db\Adapter\Pdo\\' . $config['adapter']; unset($config['adapter']); /** @var \Phalcon\Db\Adapter\Pdo $connection */ $connection = new $adapter($config); // Listen all the database events $em->attach( 'db', function ($event, $connection) use ($di) { /** * @var \Phalcon\Events\Event $event * @var \Phalcon\Db\AdapterInterface $connection * @var \Phalcon\DiInterface $di */ if ($event->getType() == 'beforeQuery') { $variables = $connection->getSQLVariables(); $string = $connection->getSQLStatement(); if ($variables) { $string .= "\n" . print_r($variables, true);; } // To disable logging change logLevel in config $di->get('logger', ['db.log'])->debug($string); } } ); // Assign the eventsManager to the db adapter instance $connection->setEventsManager($em); return $connection; }); $di->setShared('modelsManager', function () use ($em) { $modelsManager = new ModelsManager; $modelsManager->setEventsManager($em); return $modelsManager; }); $di->setShared('modelsMetadata', function () use ($config, $em) { $config = $config->get('metadata')->toArray(); $adapter = '\Phalcon\Mvc\Model\Metadata\\' . $config['adapter']; unset($config['adapter']); $metaData = new $adapter($config); return $metaData; }); } /** * Initialize the Queue Service. * TODO: Not yet implement * * Queue to deliver e-mails in real-time and other tasks. * * @param DiInterface $di Dependency Injector * @param Config $config App config * @param EventsManager $em Events Manager * * @return void */ protected function initQueue(DiInterface $di, Config $config, EventsManager $em) { $di->setShared('queue', function () use ($config) { $config = $config->get('beanstalk'); $config->get('disabled', true); if ($config->get('disabled', true)) { return new DummyServer(); } if (!$host = $config->get('host', false)) { $error = 'Beanstalk is not configured'; if (class_exists('\Phalcon\Queue\Beanstalk\Exception')) { $exception = '\Phalcon\Queue\Beanstalk\Exception'; } else { $exception = '\Phalcon\Exception'; } throw new $exception($error); } return new Beanstalk(['host' => $host]); }); } /** * Initialize the Router. * * @param DiInterface $di Dependency Injector * @param Config $config App config * @param EventsManager $em Events Manager * * @return void */ protected function initRouter(DiInterface $di, Config $config, EventsManager $em) { $di->setShared('router', function () use ($config, $em) { /** @var \Phalcon\Mvc\Router $router */ $router = include BASE_DIR . 'config/routes.php'; if (!isset($_GET['_url'])) { $router->setUriSource(Router::URI_SOURCE_SERVER_REQUEST_URI); } if (preg_match('/(.jpg|.jpge|.png|.gif|.ico|.css|.js)$/', $router->getRewriteUri())) { exit; } $router->removeExtraSlashes(true); $router->setEventsManager($em); $router->setDefaultNamespace('Blazy\Frontend\Controllers'); $router->setDefaultModule('frontend'); $router->notFound(['controller' => 'error', 'action' => 'route404']); return $router; }); } /** * Initialize the Url service. * * The URL component is used to generate all kind of urls in the application. * * @param DiInterface $di Dependency Injector * @param Config $config App config * @param EventsManager $em Events Manager * * @return void */ protected function initUrl(DiInterface $di, Config $config, EventsManager $em) { $di->setShared('url', function () use ($config) { $url = new UrlResolver; $url->setBaseUri($config->application->baseUri); $url->setStaticBaseUri(STATIC_BASE_URL . $config->application->baseUri); return $url; }); } /** * Initialize the Dispatcher. * * @param DiInterface $di Dependency Injector * @param Config $config App config * @param EventsManager $em Events Manager * * @return void */ protected function initDispatcher(DiInterface $di, Config $config, EventsManager $em) { $di->setShared('dispatcher', function () use ($em) { $dispatcher = new Dispatcher; $dispatcher->setDefaultNamespace('Blazy\Frontend\Controllers'); $em->attach('dispatch:beforeException', function ($event, $dispatcher, $exception) { if (!class_exists('Blazy\Backend\Module')) { include_once BASE_DIR . '/app/modules/backend/module.php'; $module = new Backend\Module(); $module->registerServices($this->getDI()); $module->registerAutoloaders($this->getDI()); $dispatcher->setNamespaceName('Blazy\Backend\Controllers'); } }); $dispatcher->setEventsManager($em); return $dispatcher; }); } /** * Initialize the Flash Service. * * Register the Flash Service with the Twitter Bootstrap classes * * @param DiInterface $di Dependency Injector * @param Config $config App config * @param EventsManager $em Events Manager * * @return void */ protected function initFlash(DiInterface $di, Config $config, EventsManager $em) { $di->setShared('flash', function () { $flash = new Flash( [ 'error' => 'alert alert-danger fade in', 'success' => 'alert alert-success fade in', 'notice' => 'alert alert-info fade in', 'warning' => 'alert alert-warning fade in', ] ); return $flash; }); $di->setShared('flashInline', function () use ($di) { $flash = $di->getShared('flash'); $flash->setCssClasses([ 'error' => 'custom-message error', 'success' => 'alert alert-success fade in', 'notice' => 'alert alert-info fade in', 'warning' => 'alert alert-warning fade in', ]); return $flash; }); $di->setShared( 'flashSession', function () { return new FlashSession([ 'error' => 'alert alert-danger fade in', 'success' => 'alert alert-success fade in alert-hightlight', 'notice' => 'alert alert-info fade in', 'warning' => 'alert alert-warning fade in', ]); } ); } /** * Initialize time zones. * * @param DiInterface $di Dependency Injector * @param Config $config App config * @param EventsManager $em Events Manager * * @return void */ protected function initTimezones(DiInterface $di, Config $config, EventsManager $em) { $di->setShared('timezones', function () use ($config) { return require_once BASE_DIR . 'config/timezones.php'; }); } /** * Load module's configuration file, prepare and return the Config. * * @param string $path Config path [Optional] * * @return Config * @throws RuntimeException */ protected function initConfig($path = null) { $path = $path ?: BASE_DIR . 'config/'; if (!is_readable($path . 'config.php')) { throw new RuntimeException( 'Unable to read config from ' . $path . 'config.php' ); } $di = Di::getDefault(); /** * Load default configuration and run module background job * * @var \Phalcon\Config $config */ $config = include_once $path . 'config.php'; $di->setShared('config', $config); foreach ($this->activeModules as $module) { if (is_readable(BASE_DIR . 'app/modules/' . $module . '/config.php')) $config->offsetSet($module, include_once BASE_DIR . 'app/modules/' . $module . '/config.php'); } /** * Load environment configuration * * @var \Phalcon\Config $envConfig */ $envConfig = include_once $path . 'config.' . APPLICATION_ENV . '.php'; foreach ($this->activeModules as $module) { if (is_readable(BASE_DIR . 'app/modules/' . $module . '/config.' . APPLICATION_ENV . '.php')) $envConfig->offsetSet($module, include_once BASE_DIR . 'app/modules/' . $module . '/config.' . APPLICATION_ENV . '.php'); } if ($envConfig instanceof Config) { $config->merge($envConfig); } return $config; } protected function initBackground() { $di = Di::getDefault(); foreach ($this->activeModules as $module) { if (is_readable(BASE_DIR . 'app/modules/' . $module . '/Background.php')) { include_once BASE_DIR . 'app/modules/' . $module . '/Background.php'; $background = 'Blazy\\' . $module . '\Background'; new $background($di); } } } /** * @param DiInterface $di * @param Config $config * @param EventsManager $em */ protected function initAssets(DiInterface $di, Config $config, EventsManager $em) { $di->setShared('assets', function () use ($config, $em) { return new AssetsManager(); }); } /*protected function initViewSimple(DiInterface $di, Config $config, EventsManager $em) { $di->setShared('viewSimple', function() { $view = new ViewSimple(); $view->setViewsDir($config->application->viewsDir); return new ViewSimple(); }); }*/ /** * starts the cookie the first time some component requests the cookie service * * @param DiInterface $di * @param Config $config * @param EventsManager $em */ protected function initCookie(DiInterface $di, Config $config, EventsManager $em) { $di->setShared('cookies', function () { $cookies = new Cookies(); $cookies->useEncryption(false); return $cookies; }); } /** * Multi language * * @param DiInterface $di * @param Config $config * @param EventsManager $em */ protected function initTranslate(DiInterface $di, Config $config, EventsManager $em) { $di->setShared('translate', function () use ($di, $config) { $translate = new Translate($config->application->messagesDir, $config->application->defaultLanguage); $dispatcher = $di->getShared('dispatcher'); $lang = $dispatcher->getParam('lang'); if (!empty($lang)) { $translate->setCurrentLanguage($lang); } return $translate; }); $di->setShared('t', function () use ($di, $config) { return $di->getShared('translate')->getTranslation(); }); } /** * media manager: image, video .. * * @param DiInterface $di * @param Config $config * @param EventsManager $em */ protected function initMedia(DiInterface $di, Config $config, EventsManager $em) { $di->setShared('image', new ImageManager(['driver' => 'gd'])); } public function registerActiveModules($modules, $merge = false) { $preparedModules = []; foreach ($modules as $module) { $preparedModules[$module] = [ 'className' => 'Blazy\\' . ucfirst($module) . '\\Module', 'path' => BASE_DIR . 'app/modules/' . $module . '/Module.php', ]; } parent::registerModules($preparedModules, $merge); } } |
#20 | Blazy\Bootstrap->getOutput() /var/www/sites/doctorscar/public/zohoverify/tla/config/bootstrap.php (99) <?php namespace Blazy; use Blazy\Library\Mvc\Url as UrlResolver; use Blazy\Library\Mvc\View\PhpFunctionExtension; use Intervention\Image\ImageManager; use Lamvh\Phalcon\Translate\Translate; use Phalcon\Assets\Manager as AssetsManager; use Phalcon\Cache\BackendInterface; use Phalcon\Cache\Frontend\Output as FrontOutput; use Phalcon\Config; use Phalcon\Di; use Phalcon\DiInterface; use Phalcon\Events\Event; use Phalcon\Events\Manager as EventsManager; use Phalcon\Flash\Direct as Flash; use Phalcon\Flash\Session as FlashSession; use Phalcon\Http\Response\Cookies; use Phalcon\Loader; use Phalcon\Logger\Adapter\File as FileLogger; use Phalcon\Logger\AdapterInterface as LoggerInterface; use Phalcon\Logger\Formatter\Line as FormatterLine; use Phalcon\Mvc\Application; use Phalcon\Mvc\Dispatcher; use Phalcon\Mvc\Model\Manager as ModelsManager; use Phalcon\Mvc\Router; use Phalcon\Mvc\View; use Phalcon\Mvc\View\Exception as ViewException; use Phalcon\Mvc\View\Simple as SimpleView; use Phalcon\Queue\Beanstalk; use Phalcon\Utils\Slug; use RuntimeException; class Bootstrap extends Application { private $app; private $loaders = [ 'cache', 'session', 'view', 'database', 'router', 'url', 'dispatcher', 'flash', 'timezones', 'assets', 'cookie', 'translate', 'media', ]; private $activeModules = ['frontend', 'backend', 'skeleton', 'auth', 'category', 'widget', 'mobile', 'article', 'shop']; /** * Bootstrap constructor. * * @param DiInterface $di */ public function __construct(DiInterface $di) { $em = new EventsManager; $em->enablePriorities(true); $config = $this->initConfig(); // Register the configuration itself as a service $di->setShared('eventsManager', $em); $this->app = new Application; $this->initLogger($di, $config, $em); $this->registerActiveModules($this->activeModules); $this->initLoader($di, $config, $em); foreach ($this->loaders as $service) { $serviceName = ucfirst($service); $this->{'init' . $serviceName}($di, $config, $em); } $this->initBackground(); $this->setEventsManager($em); $this->setDI($di); } /** * Runs the Application * * @return $this|string */ public function run() { if (ENV_TESTING === APPLICATION_ENV) { return $this; } return $this->getOutput(); } /** * Get application output. * * @return string */ public function getOutput() { if ($this instanceof Application) { /** * @var BackendInterface $viewCache */ if (!empty($this->config->viewCache->cacheHtml)) { $viewCache = $this->viewCache; $prefix = $this->config->viewCache->htmlPrefix; $key = $prefix . Slug::generate($this->router->getRewriteUri(), '_'); $output = $viewCache->get($key); if (empty($output)) { $output = $this->handle()->getContent(); $isMinify = false; if (!empty($this->config->minify->mode)) { if (empty($this->config->minify->condition)) { $isMinify = true; } else { $strCondition = $this->dispatcher->getModuleName() . '_' . $this->dispatcher->getControllerName() . '_' . $this->dispatcher->getActionName(); if (stripos($strCondition, $this->config->minify->condition) !== false) { $isMinify = true; } } } if (!empty($isMinify)) { $output = preg_replace('/<!--(.|\s)*?-->/', '', $output); $search = [ '/\>[^\S ]+/s', //strip whitespaces after tags, except space '/[^\S ]+\</s', //strip whitespaces before tags, except space '/(\s)+/s', // shorten multiple whitespace sequences '/>(\s)+</', '/\n/', '/\r/', '/\t/', ]; $replace = [ '>', '<', '\\1', '><', '', '', '', ]; $output = preg_replace($search, $replace, $output); } $viewCache->save($key, $output); } } else { $output = $this->handle()->getContent(); } return $output; } return $this->handle(); } /** * Initialize the Logger. * * @param DiInterface $di Dependency Injector * @param Config $config App config * @param EventsManager $em Events Manager * * @return void */ protected function initLogger(DiInterface $di, Config $config, EventsManager $em) { $di->set('logger', function ($filename = null, $format = null) use ($config) { $format = $format ?: $config->get('logger')->format; $filename = trim($filename ?: $config->get('logger')->filename, '\\/'); $path = rtrim($config->get('logger')->path, '\\/') . DIRECTORY_SEPARATOR; $formatter = new FormatterLine($format, $config->get('logger')->date); $logger = new FileLogger($path . $filename); $logger->setFormatter($formatter); $logger->setLogLevel($config->get('logger')->logLevel); return $logger; }); } /** * Initialize the Loader. * * Adds all required namespaces. * * @param DiInterface $di Dependency Injector * @param Config $config App config * @param EventsManager $em Events Manager * * @return Loader */ protected function initLoader(DiInterface $di, Config $config, EventsManager $em) { $loader = new Loader; $loader->registerNamespaces( [ 'Blazy\Library' => $config->get('application')->libraryDir, 'Blazy\Helper' => $config->get('application')->helpersDir, 'Blazy\Models' => $config->get('application')->modelsDir, 'Blazy\Plugin' => $config->get('application')->pluginsDir, 'Blazy\Constant' => $config->get('application')->constantDir, //module 'Blazy\Library\Mvc' => $config->get('application')->libraryDir . '/mvc/', 'Blazy\Library\Mvc\View' => $config->get('application')->libraryDir . '/mvc/view', 'Blazy\Util' => $config->get('application')->utilModuleDir, ] ); $loader->setEventsManager($em); $loader->register(); $di->setShared('loader', $loader); return $loader; } /** * Initialize the Cache. * * The frontend must always be Phalcon\Cache\Frontend\Output and the service 'viewCache' * must be registered as always open (not shared) in the services container (DI). * * @param DiInterface $di Dependency Injector * @param Config $config App config * @param EventsManager $em Events Manager * * @return void */ protected function initCache(DiInterface $di, Config $config, EventsManager $em) { $di->set('viewCache', function () use ($config) { $frontend = new FrontOutput(['lifetime' => $config->get('viewCache')->lifetime]); $config = $config->get('viewCache')->toArray(); $backend = '\Phalcon\Cache\Backend\\' . $config['backend']; unset($config['backend'], $config['lifetime']); return new $backend($frontend, $config); }); $di->setShared('modelsCache', function () use ($config) { $frontend = '\Phalcon\Cache\Frontend\\' . $config->get('modelsCache')->frontend; $frontend = new $frontend(['lifetime' => $config->get('modelsCache')->lifetime]); $config = $config->get('modelsCache')->toArray(); $backend = '\Phalcon\Cache\Backend\\' . $config['backend']; unset($config['backend'], $config['lifetime'], $config['frontend'], $config['useCache'], $config['isFresh']); return new $backend($frontend, $config); }); $di->setShared('dataCache', function () use ($config) { $frontend = '\Phalcon\Cache\Frontend\\' . $config->get('dataCache')->frontend; $frontend = new $frontend(['lifetime' => $config->get('dataCache')->lifetime]); $config = $config->get('dataCache')->toArray(); $backend = '\Phalcon\Cache\Backend\\' . $config['backend']; unset($config['backend'], $config['lifetime'], $config['frontend'], $config['useCache'], $config['isFresh']); return new $backend($frontend, $config); }); } /** * Initialize the Session Service. * * Start the session the first time some component request the session service. * * @param DiInterface $di Dependency Injector * @param Config $config App config * @param EventsManager $em Events Manager * * @return void */ protected function initSession(DiInterface $di, Config $config, EventsManager $em) { $di->setShared('session', function () use ($config) { $adapter = '\Phalcon\Session\Adapter\\' . $config->get('session')->adapter; /** @var \Phalcon\Session\AdapterInterface $session */ $session = new $adapter; $session->start(); return $session; }); } /** * Initialize the View. * * Setting up the view component. * * * @param DiInterface $di Dependency Injector * @param Config $config App config * @param EventsManager $em Events Manager * * @return Loader */ protected function initView(DiInterface $di, Config $config, EventsManager $em) { $di->setShared('view', function () use ($di, $config, $em) { $view = new View; $view->registerEngines([ // Setting up Volt Engine '.volt' => function ($view, $di) use ($config) { $volt = new \Phalcon\Mvc\View\Engine\Volt($view, $di); $voltConfig = $config->get('volt')->toArray(); $options = [ 'compiledPath' => $voltConfig['cacheDir'], 'compiledExtension' => $voltConfig['compiledExt'], 'compiledSeparator' => $voltConfig['separator'], 'compileAlways' => ENV_DEVELOPMENT === APPLICATION_ENV && $voltConfig['forceCompile'], ]; $volt->setOptions($options); $compiler = $volt->getCompiler(); $compiler->addExtension(new PhpFunctionExtension()); $compiler->addFunction('number_format', function ($resolvedArgs) { return 'number_format(' . $resolvedArgs . ')'; }); $compiler->addFunction('truncate', 'Lamvh\Phalcon\Utils\Str::truncateSafe'); $compiler->addFunction('in_array', 'in_array'); $compiler->addFunction('blockRender', function ($resolvedArgs, $exprArgs) { return sprintf('$this->block->render(%s)', $resolvedArgs); }); $compiler->addFunction( 'repeat', function ($resolvedArgs, $exprArgs) use ($compiler) { // Resolve the first argument $firstArgument = $compiler->expression($exprArgs[0]['expr']); // Checks if the second argument was passed if (isset($exprArgs[1])) { $secondArgument = $compiler->expression($exprArgs[1]['expr']); } else { // Use '10' as default $secondArgument = '10'; } return 'str_repeat(' . $firstArgument . ', ' . $secondArgument . ')'; } ); return $volt; }, ]); $view->setViewsDir($config->get('application')->viewsDir); $em->attach('view', function ($event, $view) use ($di, $config) { /** * @var LoggerInterface $logger * @var View $view * @var Event $event * @var DiInterface $di */ $logger = $di->get('logger'); $logger->debug(sprintf('Event %s. Path: %s', $event->getType(), $view->getActiveRenderPath())); if ('notFoundView' == $event->getType()) { $message = sprintf('View not found: %s', $view->getActiveRenderPath()); $logger->error($message); throw new ViewException($message); } }); $view->setEventsManager($em); return $view; }); $di->setShared('simpleView', function () use ($di, $config, $em) { $simpleView = new SimpleView(); $simpleView->registerEngines([ // Setting up Volt Engine '.volt' => function ($view, $di) use ($config) { $volt = new \Phalcon\Mvc\View\Engine\Volt($view, $di); $voltConfig = $config->get('volt')->toArray(); $options = [ 'compiledPath' => $voltConfig['cacheDir'], 'compiledExtension' => $voltConfig['compiledExt'], 'compiledSeparator' => $voltConfig['separator'], 'compileAlways' => ENV_DEVELOPMENT === APPLICATION_ENV && $voltConfig['forceCompile'], ]; $volt->setOptions($options); $compiler = $volt->getCompiler(); $compiler->addFunction('number_format', function ($resolvedArgs) { return 'number_format(' . $resolvedArgs . ')'; }); return $volt; }, // Setting up Php Engine '.phtml' => 'Phalcon\Mvc\View\Engine\Php', ]); $simpleView->setViewsDir($config->get('application')->viewsDir); $em->attach('simpleView', function ($event, $view) use ($di, $config) { /** * @var LoggerInterface $logger * @var View $view * @var Event $event * @var DiInterface $di */ $logger = $di->get('logger'); $logger->debug(sprintf('Event %s. Path: %s', $event->getType(), $view->getActiveRenderPath())); if ('notFoundView' == $event->getType()) { $message = sprintf('View not found: %s', $view->getActiveRenderPath()); $logger->error($message); throw new ViewException($message); } }); $simpleView->setEventsManager($em); return $simpleView; }); } /** * Initialize the Database connection. * * Database connection is created based in the parameters defined in the configuration file. * * @param DiInterface $di Dependency Injector * @param Config $config App config * @param EventsManager $em Events Manager * * @return void */ protected function initDatabase(DiInterface $di, Config $config, EventsManager $em) { $di->setShared('db', function () use ($config, $em, $di) { $config = $config->database->toArray(); $adapter = '\Phalcon\Db\Adapter\Pdo\\' . $config['adapter']; unset($config['adapter']); /** @var \Phalcon\Db\Adapter\Pdo $connection */ $connection = new $adapter($config); // Listen all the database events $em->attach( 'db', function ($event, $connection) use ($di) { /** * @var \Phalcon\Events\Event $event * @var \Phalcon\Db\AdapterInterface $connection * @var \Phalcon\DiInterface $di */ if ($event->getType() == 'beforeQuery') { $variables = $connection->getSQLVariables(); $string = $connection->getSQLStatement(); if ($variables) { $string .= "\n" . print_r($variables, true);; } // To disable logging change logLevel in config $di->get('logger', ['db.log'])->debug($string); } } ); // Assign the eventsManager to the db adapter instance $connection->setEventsManager($em); return $connection; }); $di->setShared('modelsManager', function () use ($em) { $modelsManager = new ModelsManager; $modelsManager->setEventsManager($em); return $modelsManager; }); $di->setShared('modelsMetadata', function () use ($config, $em) { $config = $config->get('metadata')->toArray(); $adapter = '\Phalcon\Mvc\Model\Metadata\\' . $config['adapter']; unset($config['adapter']); $metaData = new $adapter($config); return $metaData; }); } /** * Initialize the Queue Service. * TODO: Not yet implement * * Queue to deliver e-mails in real-time and other tasks. * * @param DiInterface $di Dependency Injector * @param Config $config App config * @param EventsManager $em Events Manager * * @return void */ protected function initQueue(DiInterface $di, Config $config, EventsManager $em) { $di->setShared('queue', function () use ($config) { $config = $config->get('beanstalk'); $config->get('disabled', true); if ($config->get('disabled', true)) { return new DummyServer(); } if (!$host = $config->get('host', false)) { $error = 'Beanstalk is not configured'; if (class_exists('\Phalcon\Queue\Beanstalk\Exception')) { $exception = '\Phalcon\Queue\Beanstalk\Exception'; } else { $exception = '\Phalcon\Exception'; } throw new $exception($error); } return new Beanstalk(['host' => $host]); }); } /** * Initialize the Router. * * @param DiInterface $di Dependency Injector * @param Config $config App config * @param EventsManager $em Events Manager * * @return void */ protected function initRouter(DiInterface $di, Config $config, EventsManager $em) { $di->setShared('router', function () use ($config, $em) { /** @var \Phalcon\Mvc\Router $router */ $router = include BASE_DIR . 'config/routes.php'; if (!isset($_GET['_url'])) { $router->setUriSource(Router::URI_SOURCE_SERVER_REQUEST_URI); } if (preg_match('/(.jpg|.jpge|.png|.gif|.ico|.css|.js)$/', $router->getRewriteUri())) { exit; } $router->removeExtraSlashes(true); $router->setEventsManager($em); $router->setDefaultNamespace('Blazy\Frontend\Controllers'); $router->setDefaultModule('frontend'); $router->notFound(['controller' => 'error', 'action' => 'route404']); return $router; }); } /** * Initialize the Url service. * * The URL component is used to generate all kind of urls in the application. * * @param DiInterface $di Dependency Injector * @param Config $config App config * @param EventsManager $em Events Manager * * @return void */ protected function initUrl(DiInterface $di, Config $config, EventsManager $em) { $di->setShared('url', function () use ($config) { $url = new UrlResolver; $url->setBaseUri($config->application->baseUri); $url->setStaticBaseUri(STATIC_BASE_URL . $config->application->baseUri); return $url; }); } /** * Initialize the Dispatcher. * * @param DiInterface $di Dependency Injector * @param Config $config App config * @param EventsManager $em Events Manager * * @return void */ protected function initDispatcher(DiInterface $di, Config $config, EventsManager $em) { $di->setShared('dispatcher', function () use ($em) { $dispatcher = new Dispatcher; $dispatcher->setDefaultNamespace('Blazy\Frontend\Controllers'); $em->attach('dispatch:beforeException', function ($event, $dispatcher, $exception) { if (!class_exists('Blazy\Backend\Module')) { include_once BASE_DIR . '/app/modules/backend/module.php'; $module = new Backend\Module(); $module->registerServices($this->getDI()); $module->registerAutoloaders($this->getDI()); $dispatcher->setNamespaceName('Blazy\Backend\Controllers'); } }); $dispatcher->setEventsManager($em); return $dispatcher; }); } /** * Initialize the Flash Service. * * Register the Flash Service with the Twitter Bootstrap classes * * @param DiInterface $di Dependency Injector * @param Config $config App config * @param EventsManager $em Events Manager * * @return void */ protected function initFlash(DiInterface $di, Config $config, EventsManager $em) { $di->setShared('flash', function () { $flash = new Flash( [ 'error' => 'alert alert-danger fade in', 'success' => 'alert alert-success fade in', 'notice' => 'alert alert-info fade in', 'warning' => 'alert alert-warning fade in', ] ); return $flash; }); $di->setShared('flashInline', function () use ($di) { $flash = $di->getShared('flash'); $flash->setCssClasses([ 'error' => 'custom-message error', 'success' => 'alert alert-success fade in', 'notice' => 'alert alert-info fade in', 'warning' => 'alert alert-warning fade in', ]); return $flash; }); $di->setShared( 'flashSession', function () { return new FlashSession([ 'error' => 'alert alert-danger fade in', 'success' => 'alert alert-success fade in alert-hightlight', 'notice' => 'alert alert-info fade in', 'warning' => 'alert alert-warning fade in', ]); } ); } /** * Initialize time zones. * * @param DiInterface $di Dependency Injector * @param Config $config App config * @param EventsManager $em Events Manager * * @return void */ protected function initTimezones(DiInterface $di, Config $config, EventsManager $em) { $di->setShared('timezones', function () use ($config) { return require_once BASE_DIR . 'config/timezones.php'; }); } /** * Load module's configuration file, prepare and return the Config. * * @param string $path Config path [Optional] * * @return Config * @throws RuntimeException */ protected function initConfig($path = null) { $path = $path ?: BASE_DIR . 'config/'; if (!is_readable($path . 'config.php')) { throw new RuntimeException( 'Unable to read config from ' . $path . 'config.php' ); } $di = Di::getDefault(); /** * Load default configuration and run module background job * * @var \Phalcon\Config $config */ $config = include_once $path . 'config.php'; $di->setShared('config', $config); foreach ($this->activeModules as $module) { if (is_readable(BASE_DIR . 'app/modules/' . $module . '/config.php')) $config->offsetSet($module, include_once BASE_DIR . 'app/modules/' . $module . '/config.php'); } /** * Load environment configuration * * @var \Phalcon\Config $envConfig */ $envConfig = include_once $path . 'config.' . APPLICATION_ENV . '.php'; foreach ($this->activeModules as $module) { if (is_readable(BASE_DIR . 'app/modules/' . $module . '/config.' . APPLICATION_ENV . '.php')) $envConfig->offsetSet($module, include_once BASE_DIR . 'app/modules/' . $module . '/config.' . APPLICATION_ENV . '.php'); } if ($envConfig instanceof Config) { $config->merge($envConfig); } return $config; } protected function initBackground() { $di = Di::getDefault(); foreach ($this->activeModules as $module) { if (is_readable(BASE_DIR . 'app/modules/' . $module . '/Background.php')) { include_once BASE_DIR . 'app/modules/' . $module . '/Background.php'; $background = 'Blazy\\' . $module . '\Background'; new $background($di); } } } /** * @param DiInterface $di * @param Config $config * @param EventsManager $em */ protected function initAssets(DiInterface $di, Config $config, EventsManager $em) { $di->setShared('assets', function () use ($config, $em) { return new AssetsManager(); }); } /*protected function initViewSimple(DiInterface $di, Config $config, EventsManager $em) { $di->setShared('viewSimple', function() { $view = new ViewSimple(); $view->setViewsDir($config->application->viewsDir); return new ViewSimple(); }); }*/ /** * starts the cookie the first time some component requests the cookie service * * @param DiInterface $di * @param Config $config * @param EventsManager $em */ protected function initCookie(DiInterface $di, Config $config, EventsManager $em) { $di->setShared('cookies', function () { $cookies = new Cookies(); $cookies->useEncryption(false); return $cookies; }); } /** * Multi language * * @param DiInterface $di * @param Config $config * @param EventsManager $em */ protected function initTranslate(DiInterface $di, Config $config, EventsManager $em) { $di->setShared('translate', function () use ($di, $config) { $translate = new Translate($config->application->messagesDir, $config->application->defaultLanguage); $dispatcher = $di->getShared('dispatcher'); $lang = $dispatcher->getParam('lang'); if (!empty($lang)) { $translate->setCurrentLanguage($lang); } return $translate; }); $di->setShared('t', function () use ($di, $config) { return $di->getShared('translate')->getTranslation(); }); } /** * media manager: image, video .. * * @param DiInterface $di * @param Config $config * @param EventsManager $em */ protected function initMedia(DiInterface $di, Config $config, EventsManager $em) { $di->setShared('image', new ImageManager(['driver' => 'gd'])); } public function registerActiveModules($modules, $merge = false) { $preparedModules = []; foreach ($modules as $module) { $preparedModules[$module] = [ 'className' => 'Blazy\\' . ucfirst($module) . '\\Module', 'path' => BASE_DIR . 'app/modules/' . $module . '/Module.php', ]; } parent::registerModules($preparedModules, $merge); } } |
#21 | Blazy\Bootstrap->run() /var/www/sites/doctorscar/public/zohoverify/tla/public/index.php (19) <?php use Blazy\Bootstrap; include_once realpath(dirname(dirname(__FILE__))) . '/config/env.php'; include_once BASE_DIR . 'config/bootstrap.php'; $app = new Bootstrap(new \Phalcon\Di\FactoryDefault()); //if ( APPLICATION_ENV == ENV_DEVELOPMENT) { // $di = Phalcon\Di::getDefault(); // //$application = new Phalcon\Mvc\Application( $di ); // Important: mustn't ignore $di param . The Same Micro APP: new Phalcon\Mvc\Micro($di); // $di['app'] = $app; // Important // (new Snowair\Debugbar\ServiceProvider( BASE_DIR . 'config/debugbar.php'))->start(); //} if (APPLICATION_ENV == ENV_TESTING) { return $app->run(); } else { echo $app->run(); } |
Key | Value |
---|
Key | Value |
---|---|
USER | nginx |
HOME | /var/cache/nginx |
FCGI_ROLE | RESPONDER |
QUERY_STRING | |
REQUEST_METHOD | GET |
CONTENT_TYPE | |
CONTENT_LENGTH | |
SCRIPT_NAME | /index.php |
REQUEST_URI | / |
DOCUMENT_URI | /index.php |
DOCUMENT_ROOT | /var/www/sites/doctorscar/public/zohoverify/tla/public |
SERVER_PROTOCOL | HTTP/1.1 |
REQUEST_SCHEME | https |
HTTPS | on |
GATEWAY_INTERFACE | CGI/1.1 |
SERVER_SOFTWARE | nginx/1.16.1 |
REMOTE_ADDR | 18.118.119.77 |
REMOTE_PORT | 39229 |
SERVER_ADDR | 103.200.22.147 |
SERVER_PORT | 443 |
SERVER_NAME | tlaadvertising.com.vn |
REDIRECT_STATUS | 200 |
GEOIP_ADDR | 18.118.119.77 |
PATH_INFO | |
PATH_TRANSLATED | /var/www/sites/doctorscar/public/zohoverify/tla/public |
SCRIPT_FILENAME | /var/www/sites/doctorscar/public/zohoverify/tla/public/index.php |
HTTP_ACCEPT | */* |
HTTP_USER_AGENT | Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com) |
HTTP_ACCEPT_ENCODING | gzip, br, zstd, deflate |
HTTP_HOST | tlaadvertising.com.vn |
PHP_SELF | /index.php |
REQUEST_TIME_FLOAT | 1732165466.5295 |
REQUEST_TIME | 1732165466 |
APP_ENV | development |
# | Path |
---|---|
0 | /var/www/sites/doctorscar/public/zohoverify/tla/public/index.php |
1 | /var/www/sites/doctorscar/public/zohoverify/tla/config/env.php |
2 | /var/www/sites/doctorscar/public/zohoverify/tla/vendor/autoload.php |
3 | /var/www/sites/doctorscar/public/zohoverify/tla/vendor/composer/autoload_real.php |
4 | /var/www/sites/doctorscar/public/zohoverify/tla/vendor/composer/ClassLoader.php |
5 | /var/www/sites/doctorscar/public/zohoverify/tla/vendor/composer/autoload_static.php |
6 | /var/www/sites/doctorscar/public/zohoverify/tla/vendor/ralouphie/getallheaders/src/getallheaders.php |
7 | /var/www/sites/doctorscar/public/zohoverify/tla/vendor/symfony/polyfill-ctype/bootstrap.php |
8 | /var/www/sites/doctorscar/public/zohoverify/tla/vendor/guzzlehttp/psr7/src/functions_include.php |
9 | /var/www/sites/doctorscar/public/zohoverify/tla/vendor/guzzlehttp/psr7/src/functions.php |
10 | /var/www/sites/doctorscar/public/zohoverify/tla/vendor/swiftmailer/swiftmailer/lib/swift_required.php |
11 | /var/www/sites/doctorscar/public/zohoverify/tla/vendor/swiftmailer/swiftmailer/lib/classes/Swift.php |
12 | /var/www/sites/doctorscar/public/zohoverify/tla/vendor/vlucas/phpdotenv/src/Dotenv.php |
13 | /var/www/sites/doctorscar/public/zohoverify/tla/vendor/vlucas/phpdotenv/src/Loader.php |
14 | /var/www/sites/doctorscar/public/zohoverify/tla/vendor/vlucas/phpdotenv/src/Parser.php |
15 | /var/www/sites/doctorscar/public/zohoverify/tla/vendor/lamvh/phalcon/src/error/Handler.php |
16 | /var/www/sites/doctorscar/public/zohoverify/tla/config/bootstrap.php |
17 | /var/www/sites/doctorscar/public/zohoverify/tla/config/config.php |
18 | /var/www/sites/doctorscar/public/zohoverify/tla/app/modules/skeleton/config.php |
19 | /var/www/sites/doctorscar/public/zohoverify/tla/config/config.development.php |
20 | /var/www/sites/doctorscar/public/zohoverify/tla/app/modules/skeleton/config.development.php |
21 | /var/www/sites/doctorscar/public/zohoverify/tla/vendor/intervention/image/src/Intervention/Image/ImageManager.php |
22 | /var/www/sites/doctorscar/public/zohoverify/tla/app/modules/frontend/Background.php |
23 | /var/www/sites/doctorscar/public/zohoverify/tla/vendor/lamvh/phalcon/src/Mvc/BackgroundServiceInterface.php |
24 | /var/www/sites/doctorscar/public/zohoverify/tla/app/modules/frontend/config/config.php |
25 | /var/www/sites/doctorscar/public/zohoverify/tla/vendor/lamvh/phalcon/src/translate/Translate.php |
26 | /var/www/sites/doctorscar/public/zohoverify/tla/app/modules/backend/Background.php |
27 | /var/www/sites/doctorscar/public/zohoverify/tla/app/modules/backend/config/config.php |
28 | /var/www/sites/doctorscar/public/zohoverify/tla/app/modules/backend/Routes.php |
29 | /var/www/sites/doctorscar/public/zohoverify/tla/config/routes.php |
30 | /var/www/sites/doctorscar/public/zohoverify/tla/app/modules/skeleton/Background.php |
31 | /var/www/sites/doctorscar/public/zohoverify/tla/app/modules/auth/Background.php |
32 | /var/www/sites/doctorscar/public/zohoverify/tla/app/modules/auth/config/config.php |
33 | /var/www/sites/doctorscar/public/zohoverify/tla/app/modules/auth/Routes.php |
34 | /var/www/sites/doctorscar/public/zohoverify/tla/app/modules/auth/plugin/Security.php |
35 | /var/www/sites/doctorscar/public/zohoverify/tla/app/modules/category/Background.php |
36 | /var/www/sites/doctorscar/public/zohoverify/tla/app/modules/category/config/config.php |
37 | /var/www/sites/doctorscar/public/zohoverify/tla/app/modules/category/Routes.php |
38 | /var/www/sites/doctorscar/public/zohoverify/tla/app/modules/widget/Background.php |
39 | /var/www/sites/doctorscar/public/zohoverify/tla/app/modules/widget/config/config.php |
40 | /var/www/sites/doctorscar/public/zohoverify/tla/app/modules/mobile/Background.php |
41 | /var/www/sites/doctorscar/public/zohoverify/tla/app/modules/mobile/config/config.php |
42 | /var/www/sites/doctorscar/public/zohoverify/tla/app/modules/mobile/plugin/MobileDetect.php |
43 | /var/www/sites/doctorscar/public/zohoverify/tla/app/modules/article/Background.php |
44 | /var/www/sites/doctorscar/public/zohoverify/tla/app/modules/article/config/config.php |
45 | /var/www/sites/doctorscar/public/zohoverify/tla/app/modules/article/Routes.php |
46 | /var/www/sites/doctorscar/public/zohoverify/tla/app/modules/article/plugin/Seo.php |
47 | /var/www/sites/doctorscar/public/zohoverify/tla/app/modules/shop/Background.php |
48 | /var/www/sites/doctorscar/public/zohoverify/tla/app/modules/shop/config/config.php |
49 | /var/www/sites/doctorscar/public/zohoverify/tla/vendor/lamvh/phalcon/src/auth/library/Authentication.php |
50 | /var/www/sites/doctorscar/public/zohoverify/tla/app/modules/auth/library/UsernameAccountType.php |
51 | /var/www/sites/doctorscar/public/zohoverify/tla/vendor/lamvh/phalcon/src/auth/library/AccountTypeInterface.php |
52 | /var/www/sites/doctorscar/public/zohoverify/tla/app/modules/auth/library/EmailAccountType.php |
53 | /var/www/sites/doctorscar/public/zohoverify/tla/app/modules/auth/library/FacebookAccountType.php |
54 | /var/www/sites/doctorscar/public/zohoverify/tla/app/modules/auth/library/GoogleAccountType.php |
55 | /var/www/sites/doctorscar/public/zohoverify/tla/app/modules/shop/Routes.php |
56 | /var/www/sites/doctorscar/public/zohoverify/tla/app/modules/shop/Module.php |
57 | /var/www/sites/doctorscar/public/zohoverify/tla/vendor/lamvh/phalcon/src/auth/models/Role.php |
58 | /var/www/sites/doctorscar/public/zohoverify/tla/vendor/lamvh/phalcon/src/mvc/models/CacheableModel.php |
Memory | |
---|---|
Usage | 2097152 |