Get the Debug Bar instance
@throws Exception
@global array $databaseConfig
@return BaseDebugBar
326392
public static function getDebugBar()
    {
        if (self::$debugbar !== null) {
            return self::$debugbar;
        }

        $reasons = self::disabledCriteria();
        if (!empty($reasons)) {
            self::$debugbar = false; // no need to check again
            return;
        }

        self::initDebugBar();

        if (!self::$debugbar) {
            throw new Exception("Failed to initialize the DebugBar");
        }

        return self::$debugbar;
    }
585625
protected function createSerializer(array $config, $debug)
    {
        $builder = new SerializerBuilder;

        if (isset($config['cache_dir'])) {
            $builder->setCacheDir($config['cache_dir']);
        }

        if (isset($config['default_handlers'])) {
            $builder->addDefaultHandlers();
        }

        if (isset($config['handlers'])) {
            foreach ($config['handlers'] as $handler) {
                $builder->configureHandlers($handler);
            }
        }

        if (isset($config['event_listeners'])) {
            foreach ($config['event_listeners'] as $handler) {
                $builder->configureListeners($handler);
            }
        }

        $builder->addMetadataDirs(array_get($config, 'paths', [base_path('app')]));
        $builder->setDebug($debug);

        return $builder->build();
    }
706776
private function getDebugLogger()
    {
        foreach ($this->processors as $processor) {
            if ($processor instanceof DebugLoggerInterface) {
                return $processor;
            }
        }

        foreach ($this->handlers as $handler) {
            if ($handler instanceof DebugLoggerInterface) {
                return $handler;
            }
        }
    }
975348
public function getConnection()
    {
        try {
            if ($this->instancia == null) {

                $json = new JsonReader(BASE_DIR . self::PATH_CONFIG_FILE);

                if (!empty(glob(dirname(__DIR__, 4) . self::PATH_CONFIG_FILE )[0])) {
                    $json = new JsonReader(glob(dirname(__DIR__, 4) . PATH_CONFIG_FILE)[0]);
                }

                $json= $json->read();
                try {

                    $connectionCache = $json->phiber->link->connection_cache == 1 ? true : false;

                    $this->instancia = new PDO(
                        $json->phiber->link->url,
                        $json->phiber->link->user,
                        $json->phiber->link->password,
                        array(
                            PDO::ATTR_PERSISTENT => $connectionCache
                        )
                    );
                } catch (PhiberException $e) {
                    throw new PhiberException(new Internationalization("database_connection_error"));
                }
            }

            return $this->instancia;

        } catch (PhiberException $e) {
            throw new PhiberException(new Internationalization("database_connection_error"));
        }
    }
10296
public function setDbConn($dbconfig = [])
    {
        if (empty($dbconfig)) {
            $this->dbconfig = config('database');
            //$this->dbconfig = Config::get('database');
        } else {
            $this->dbconfig = $dbconfig;
        }
        return $this;
    }
358321
protected function loadDatabaseConfig()
    {
        if (!$this->databaseConfigFile) {
            return null;
        }

        $configPath = "{$this->path}/{$this->databaseConfigFile}";
        if (file_exists($configPath)) {
            $this->databaseConfig = require $configPath;
        } else {
            throw new Exception("Unable to load database configuration.");
        }
    }
749389
protected function getParser()
    {
        $driver = strtolower(DB::getDriverName());

        if (!in_array($driver, $this->drivers)) {
            throw new Exception('The database driver user is not supported!');
        }

        $class = sprintf('CrestApps\CodeGenerator\DatabaseParsers\%sParser', ucfirst($driver));

        return new $class($this->getTableName(), $this->getDatabaseName(), $this->getLanguages());
    }
580792
public static function getInstance($config, $classname = 'IDS_Log_Database')
    {
        if ($config instanceof IDS_Init) {
            $wrapper = $config->config['Logging']['wrapper'];
        } elseif (is_array($config)) {
            $wrapper = $config['wrapper'];
        }

        if (!isset(self::$instances[$wrapper])) {
            self::$instances[$wrapper] = new $classname($config);
        }

        return self::$instances[$wrapper];
    }
425339
protected function getDatabaseConnectionConfig($connection)
    {
        $connections = $this->proxy->get('database.connections');
        if (!isset($connections[$connection])) {
            throw new Exception('Unknown database connection: ' . $connection);
        }
        $config = $connections[$connection];
        if (!in_array($config['driver'], ['mysql', 'pgsql'])) {
            throw new Exception('Currently only MySQL and PostgreSQL databases are supported using the laravel config');
        }
        return $config;
    }
438375
public static function getConnection($dsn)
    {
        if (!is_array($dsn)) {
            $dsn = self::parseDsn($dsn);
        }
        if (!isset($dsn['adapter'])) {
            throw new Exception("database adapter is missing for " . json_encode($dsn));
        }
        $class = 'Phalcon\Db\Adapter\Pdo\\' . ucfirst($dsn['adapter']);
        $conn = new $class($dsn);
        return Mixin::create($conn, new self);
    }
117558
public static function get(array $config)
    {
        if (!isset($config['driver']) || !$config['driver']) {
            throw new \RuntimeException('no driver specified');
        }

        $driver = strtolower($config['driver']);

        if (!in_array($driver, array('sqlite', 'mysql', 'sqlserver', 'postgre'), true)) {
            throw new \UnexpectedValueException('PDO driver "' . $driver . '" not supported by PIMF');
        }

        if (!extension_loaded('pdo') || !extension_loaded('pdo_' . $driver)) {
            throw new \RuntimeException('Please navigate to "http://php.net/manual/pdo.installation.php" '
                . ' to find out how to install "PDO" with "pdo_' . $driver . '" on your system!');
        }

        $driver = '\Pimf\Pdo\\' . ucfirst($driver);

        $pdo = new $driver();

        return $pdo->connect($config);
    }
1247607
public function connect(array $config)
    {
        return new DatabaseQueue(
            $this->connections->connection(array_get($config, 'connection')),
            array_get($config, 'table', 'queues'),
            array_get($config, 'queue', null),
            array_get($config, 'expire', 60),
            array_get($config, 'lock_type', 60)
        );
    }
1363886
protected function getDatabaseConfig()
    {
        /** @skipUpgrade */
        $databaseConfig = [
            "type" => Environment::getEnv('SS_DATABASE_CLASS') ?: 'MySQLDatabase',
            "server" => Environment::getEnv('SS_DATABASE_SERVER') ?: 'localhost',
            "username" => Environment::getEnv('SS_DATABASE_USERNAME') ?: null,
            "password" => Environment::getEnv('SS_DATABASE_PASSWORD') ?: null,
        ];

        // Set the port if called for
        $dbPort = Environment::getEnv('SS_DATABASE_PORT');
        if ($dbPort) {
            $databaseConfig['port'] = $dbPort;
        }

        // Set the timezone if called for
        $dbTZ = Environment::getEnv('SS_DATABASE_TIMEZONE');
        if ($dbTZ) {
            $databaseConfig['timezone'] = $dbTZ;
        }

        // For schema enabled drivers:
        $dbSchema = Environment::getEnv('SS_DATABASE_SCHEMA');
        if ($dbSchema) {
            $databaseConfig["schema"] = $dbSchema;
        }

        // For SQlite3 memory databases (mainly for testing purposes)
        $dbMemory = Environment::getEnv('SS_DATABASE_MEMORY');
        if ($dbMemory) {
            $databaseConfig["memory"] = $dbMemory;
        }

        // Allow database adapters to handle their own configuration
        DatabaseAdapterRegistry::autoconfigure($databaseConfig);
        return $databaseConfig;
    }
955847
public function getConfigArray()
    {
        if ($this->_configArray === null) {
            if (!file_exists($this->configFile)) {
                if (!$this->getIsCli()) {
                    throw new Exception("Unable to load the config file '".$this->configFile."'.");
                }
                
                $config = ['id' => 'consoleapp', 'basePath' => dirname(__DIR__)];
            } else {
                $config = require $this->configFile;
            }
    
            if (!is_array($config)) {
                throw new Exception("config file '".$this->configFile."' found but no array returning.");
            }
            
            // preset the values from the defaultConfigArray
            if (!empty($this->prependConfigArray())) {
                $config = ArrayHelper::merge($config, $this->prependConfigArray());
            }
         
            $this->_configArray = $config;
        }

        return $this->_configArray;
    }
693728
public function getAdapter()
    {
        if (is_null($this->adapter) || ! $this->adapter instanceof AdapterInterface) {
            $class = '\\Wslim\\Db\Adapter\\' . $this->options['adapter'] . 'Adapter';
            if (!class_exists($class)) {
                throw new DbException('database adapter is not exists:' . $class);
            }
            
            $this->adapter  =   new $class($this->options);
        }
        
        return $this->adapter;
    }
287267
protected function getDblibDsn(array $config)
	{
		$arguments = array(
			'host' => $this->buildHostString($config, ':'),
			'dbname' => $config['database']
		);

		$arguments = array_merge(
			$arguments, array_only($config, ['appname', 'charset'])
		);

		return $this->buildConnectString('dblib', $arguments);
	}
78562
public function pdoWithoutDB()
    {
        $this->checkConfiguration();

        try {
            return new PDO(
                $this->buildDsn(false),
                $this->config['username'],
                $this->config['password']
            );
        } catch (Exception $e) {
            throw new RuntimeException(static::E_CONNECT);
        }
    }