Jump to content

Problems connecting to a database via Doctrine on server vs localhost


Houden

Recommended Posts

I've been looking to get into using Doctrine for one of my projects these past couple of days and while on my localhost everything has been working perfectly fine so far I've had trouble even getting the application to run once I uploaded the things to the server today. 

Accessing my testpage gives me the following error message which obviously suggests that something's going wrong when I'm trying to connect to the database.

RedisException Object ( [message:protected] => Connection refused [string:Exception:private] => [code:protected] => 0 [file:protected] => /var/www/vhosts/dbzt.de/api.dbzt.de/v1/vendor/doctrine/orm/lib/Doctrine/ORM/ORMSetup.php [line:protected] => 194 [trace:Exception:private] => Array ( [0] => Array ( [file] => /var/www/vhosts/dbzt.de/api.dbzt.de/v1/vendor/doctrine/orm/lib/Doctrine/ORM/ORMSetup.php [line] => 194 [function] => connect [class] => Redis [type] => -> ) [1] => Array ( [file] => /var/www/vhosts/dbzt.de/api.dbzt.de/v1/vendor/doctrine/orm/lib/Doctrine/ORM/ORMSetup.php [line] => 148 [function] => createCacheInstance [class] => Doctrine\ORM\ORMSetup [type] => :: ) [2] => Array ( [file] => /var/www/vhosts/dbzt.de/api.dbzt.de/v1/vendor/doctrine/orm/lib/Doctrine/ORM/ORMSetup.php [line] => 42 [function] => createConfiguration [class] => Doctrine\ORM\ORMSetup [type] => :: ) [3] => Array ( [file] => /var/www/vhosts/dbzt.de/api.dbzt.de/v1/config/Database.php [line] => 28 [function] => createAnnotationMetadataConfiguration [class] => Doctrine\ORM\ORMSetup [type] => :: ) [4] => Array ( [file] => /var/www/vhosts/dbzt.de/api.dbzt.de/v1/config/Database.php [line] => 20 [function] => createEntityManager [class] => Database [type] => -> ) [5] => Array ( [file] => /var/www/vhosts/dbzt.de/api.dbzt.de/v1/entity/Dungeon.php [line] => 69 [function] => __construct [class] => Database [type] => -> ) [6] => Array ( [file] => /var/www/vhosts/dbzt.de/api.dbzt.de/v1/endpoints/get/dungeon.php [line] => 6 [function] => __construct [class] => Dungeon [type] => -> ) ) [previous:Exception:private] => )

 

The part of my database class that handles the initial connection and is thus, most likely, at fault for the error looks as follows

	/* Dev Env
	    public $params = [
            'host' => 'localhost',
            'user' => 'root',
            'password' => 'myPass',
            'dbname' => 'dbzt',
            'driver' => 'pdo_mysql'
    	];
    */

    /* Prod Env */
    public $params = [
        'host' => 'localhost',
        'user' => 'devadmin',
        'password' => 'myPass',
        'dbname' => 'dbztdev',
        'driver' => 'pdo_mysql'
    ];

    private $entityManager;


    public function __construct()
    {
        $this->createEntityManager();
    }

    public function createEntityManager()
    {
        try
        {
            $this->entityManager = EntityManager::create($this->params,
                                   			ORM\ORMSetup::createAnnotationMetadataConfiguration([__DIR__.'/../entity']));
        }
        catch (Exception $e)
        {
            print_r($e);
        }
    }

 

Running this on localhost with the Dev Params enabled instead of the Prod ones runs perfectly but as soon as I make the switch I get this weird problem. I've also tried using the 'url' parameter lined out in the Doctrine docs instead, leading to the same result, same with trying to add an explicit port to the params in case something was wrong there.

 

What are some other things I could try to troubleshoot in this situation?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.