Db_Initiate Not Working

Having issue connecting to database running 4.3.9 , lamp stack, no core modification

define('REQUIRE_SECURE', true);
error_reporting(E_ALL ^ (E_NOTICE | E_WARNING | E_DEPRECATED));
header('Access-Control-Allow-Origin: https://www.sitename.com'); 

use Tygh\Bootstrap;
use Tygh\Exceptions\DatabaseException;
use Tygh\Registry;

// Register autoloader
$this_dir = dirname(FILE);
$classLoader = require($this_dir . ‘/app/lib/vendor/autoload.php’);
$classLoader->add(‘Tygh’, $this_dir . ‘/app’);

// Prepare environment and process request vars
list($_REQUEST, $_SERVER) = Bootstrap::initEnv($_GET, $_POST, $_SERVER, $this_dir);

// Get config data
$config = require(DIR_ROOT . ‘/config.php’);

// Load core functions
$fn_list = array(

$fn_list[] = ‘fn.’ . strtolower(PRODUCT_EDITION) . ‘.php’;

foreach ($fn_list as $file) {
require($config[‘dir’][‘functions’] . $file);

Registry::set(‘class_loader’, $classLoader);
Registry::set(‘config’, $config);

// Connect to database
if (!db_initiate(Registry::get(‘config.db_host’), Registry::get(‘config.db_user’), Registry::get(‘config.db_password’), Registry::get(‘config.db_name’))) {
throw new DatabaseException(‘Cannot connect to the database server’);


Fatal error: Class 'Tygh' not found in /home/use/www/app/functions/fn.database.php on line 243

line 243 contains

 * Connect to database server and select database
 * @param string $host database host
 * @param string $user database user
 * @param string $password database password
 * @param string $name database name
 * @param array  $params additional connection parameters (name, table prefix)
 * @return resource database connection identifier, false if error occurred
function db_initiate($host, $user, $password, $name, $params = array())
 /* 243 ->*/   $is_connected = Tygh::$app['db']->connect($user, $password, $host, $name, $params);
if ($is_connected) {
    Registry::set('runtime.database.skip_errors', false);
    return true;
return false;


I can get Registry component and settings, to it is seeming to find Tygh, the frontend works just fine, with dba settings

if I add in the class_alias as other users have done :

// Register autoloader
$this_dir = dirname(__FILE__);
$classLoader = require($this_dir . '/app/lib/vendor/autoload.php');
$classLoader->add('Tygh', $this_dir . '/app');
class_alias('\Tygh\Tygh', 'Tygh');

I get the error

Fatal error: Call to a member function connect() on null in /home/user/www/app/functions/fn.database.php on line 243

Any ideas? Maybe mysql(i) driver? at my wits end with this one.

What are you trying to accomplish? Seems that re-factoring a portion of the initialization process might not be the right approach for you.

Please provide description of what you want to do.

@sublok: Have you sort it out?

I'm facing the same thing on a Wamp stack and on production server with one of the integrations with a third party store.

Looking forward your reply!