title: How to properly initialize database connection in Phalcon
body: <p>at the moment, I initialize database in following way:</p>
  
  <pre><code>$di-&gt;set('db', function() use ($config){
      return new \Phalcon\Db\Adapter\Pdo\Mysql(
          array(
              "host" =&gt; $config-&gt;database-&gt;host,
              "username" =&gt; $config-&gt;database-&gt;username,
              "password" =&gt; $config-&gt;database-&gt;password,
              "dbname" =&gt; $config-&gt;database-&gt;name
          )
      );
  });
  </code></pre>
  
  <p>but when mysql credentials are wrong, or database doesn't exist, Phalcon returns blank page without any error message. Such situations are real headache, because small error in login/password/host causes almost untraceable error.</p>
  
  <p>I think that Pdo constructor stops PHP code execution in this case.</p>
  
  <p>So how do you initialize database connection in Phalcon when you want website to tell you about problem with database?</p>