public function offsetGet($id) { if (!$this->offsetExists($id)) { if (array_key_exists($id, $this->keys)) { $file = $this->keys[$id]; if (!file_exists($file)) { $file = null; } } else { $arr = array('php', 'ini', 'yml', 'json', 'cache'); foreach ($arr as $v) { $file = $this->configDir . "/" . $id . "." . $v; if (file_exists($file)) { break; } else { $file = null; } } } \Fobia\Debug\Log::debug(">> autoload config", array($id, $file)); if (!$file) { trigger_error("Нет автозагрузочной секции конфигурации '{$id}'" . "/{$file}", E_USER_ERROR); return; } $this->values[$id] = Utils::loadConfig($file); } return $this->values[$id]; }
/** * * @param \Fobia\Base\Application $app * @param array $map * @internal */ public function __construct(Application $app, $map = array()) { $this->app = $app; $this->map = array_merge($this->map, $map); $this->status = self::STATUS_AUTH_NONE; if (class_exists('\\Fobia\\Debug\\Log')) { $this->logger = \Fobia\Debug\Log::getLogger(); } else { $this->logger = new \Psr\Log\NullLogger(); } }
public function offsetGet($id) { if (!$this->offsetExists($id)) { $this[$id] = function ($c) use($id) { $arr = array('php', 'ini', 'yml', 'json', 'cache'); $configDir = $c['configDir'](); foreach ($arr as $v) { $file = $configDir . "/" . $id . "." . $v; if (file_exists($file)) { break; } else { $file = null; } } \Fobia\Debug\Log::debug(">> autoload config", array($id, $file)); if (!$file) { trigger_error("Нет автозагрузочной секции конфигурации '{$id}'" . "/{$file}", E_USER_ERROR); return; } return Utils::loadConfig($file); }; } return parent::offsetGet($id); }
/** * Создает объект из параметров $dbParams. * * Supported database parameters are: * - dbname|database: Database name * - user|username: Database user name * - pass|password: Database user password * - host|hostspec: Name of the host database is running on * - port: TCP port * - charset: Client character set * - socket: UNIX socket path * * @param array $dbParams Database connection parameters (key=>value pairs). */ public function __construct(array $dbParams) { parent::__construct($dbParams); $this->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC); $this->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT); $this->setAttribute(PDO::ATTR_STATEMENT_CLASS, array('Fobia\\DataBase\\DbStatement', array($this))); if (@$dbParams['params']['logger'] instanceof \Psr\Log\LoggerInterface) { $this->logger = $dbParams['params']['logger']; } else { $this->logger = class_exists('\\Fobia\\Debug\\Log') ? \Fobia\Debug\Log::getLogger() : new \Psr\Log\NullLogger(); } if (isset($dbParams['params']['log_error'])) { $this->log_error = $dbParams['params']['log_error']; } // if (@$dbParams['charset']) { // parent::query("SET NAMES '{$dbParams['charset']}'"); // } $this->getLogger()->info('[SQL]:: Connect database', array($dbParams['database'])); if (@$dbParams['params']['debug']) { parent::query('SET profiling = 1'); $this->profiles = true; $this->logger->debug('==> Set profiling'); } }
<?php /** * bootstrap.php file * * @author Dmitriy Tyurin <*****@*****.**> * @copyright Copyright (c) 2014 Dmitriy Tyurin */ $logger = (require dirname(__DIR__) . '/vendor/autoload.php'); /* @var $logger \Composer\Autoload\ClassLoader */ $loader->add('', __DIR__ . '/tests'); // $logger->add("Fobia\\DataBase\\", __DIR__); //$logger->setPsr4("Fobia\\DataBase\\", __DIR__); // var_dump($logger); if (class_exists('\\Fobia\\Debug\\Log')) { \Fobia\Debug\Log::setLogger(new \Psr\Log\NullLogger()); }
protected function dispatchRequest(\Slim\Http\Request $request, \Slim\Http\Response $response) { Log::debug('App run dispatch request'); try { $this->applyHook('slim.before'); ob_start(); $this->applyHook('slim.before.router'); $dispatched = false; $matchedRoutes = $this['router']->getMatchedRoutes($request->getMethod(), $request->getPathInfo(), true); foreach ($matchedRoutes as $route) { /* @var $route \Slim\Route */ try { $this->applyHook('slim.before.dispatch'); $dispatched = $route->dispatch(); $this->applyHook('slim.after.dispatch'); if ($dispatched) { Log::debug('Route dispatched: ' . $route->getPattern()); break; } } catch (\Slim\Exception\Pass $e) { continue; } } if (!$dispatched) { $this->notFound(); } $this->applyHook('slim.after.router'); } catch (\Slim\Exception\Stop $e) { } $response->write(ob_get_clean()); $this->applyHook('slim.after'); }