public function register() { $configPath = $this->configPath; $this->di->set('config.debugbar', function () use($configPath) { $base = new Php(__DIR__ . '/config/debugbar.php'); $base['collectors']['phpinfo'] = true; $base['collectors']['time'] = true; $base['collectors']['messages'] = true; if (is_string($configPath) && is_file($configPath)) { $config = new Php($configPath); $base->merge($config); } elseif (is_object($configPath) && $configPath instanceof Php) { $base->merge($configPath); } else { } return $base; }, true); $this->di->set('debugbar', function () { $di = Version::getId() > 2010000 ? $this : $this->di; $debugbar = new PhalconDebugbar($di); $debugbar->setHttpDriver(new PhalconHttpDriver()); return $debugbar; }); $this->setRoute(); return $this; }
public function register() { $configPath = $this->configPath; $this->di->set('config.debugbar', function () use($configPath) { $base = new Php(__DIR__ . '/config/debugbar.php'); $base['collectors']['phpinfo'] = true; $base['collectors']['time'] = true; $base['collectors']['messages'] = true; if (is_string($configPath) && is_file($configPath)) { $extension = strtolower(pathinfo($configPath, PATHINFO_EXTENSION)); switch ($extension) { case 'ini': $config = new Ini($configPath); break; case 'json': $config = new Json($configPath); break; case 'php': case 'php5': case 'inc': $config = new Php($configPath); break; case 'yml': case 'yaml': $config = new Yaml($configPath); break; default: throw new \RuntimeException(sprintf('Config adapter for %s files is not support', $extension)); } $base->merge($config); } elseif (is_object($configPath) && $configPath instanceof Config) { $base->merge($configPath); } else { } return $base; }, true); $this->di->set('debugbar', function () { $di = Version::getId() > 2010000 ? $this : $this->di; $debugbar = new PhalconDebugbar($di); $debugbar->setHttpDriver(new PhalconHttpDriver()); return $debugbar; }); $this->setRoute(); return $this; }
<?php use Phalcon\Mvc\View\Simple as SimpleView; use Phalcon\Di\FactoryDefault; use Phalcon\Config\Adapter\Php as PhpConfig; $di = new FactoryDefault(); $di->set('config', function () { $config = new PhpConfig(__DIR__ . '/app.php'); if (is_readable(__DIR__ . '/app.development.php') && getenv('APPLICATION_ENV') == 'development') { $development = new PhpConfig(__DIR__ . '/app.development.php'); $config->merge($development); } return $config; }, true); $di->set('view', function () use($di) { $config = $di->get('config')['view']; $view = new SimpleView(); $view->setViewsDir($config['dir']); $view->setVar('appConfig', $di->get('config')['app']); $view->setVar('flashSession', $di->get('flashSession')); $engine = new $config['engine']($view); $engine->setOptions([$config['options']]); $view->registerEngines([$config['prefix'] => $engine]); return $view; }, true); $di->set('connection', function () use($di) { $config = $di->get('config')['database']; $adapter = new $config->adapter(["host" => $config->host, "username" => $config->username, "password" => $config->password, "dbname" => $config->db]); return $adapter; }, true);