<p>Solved. The config/db.php cloned from Hyperlane refers to different env variable names than those used within my .env file. Changing the names in config/db.php solved the issue.</p>

<p>Before:</p>

<pre><code>return [
    'driver' =&gt; getenv('DB_DRIVER'),
    'server' =&gt; getenv('DB_HOST'),
    'user' =&gt; getenv('DB_USER'),
    'password' =&gt; getenv('DB_PASSWORD'),
    'database' =&gt; getenv('DB_NAME'),
    'schema' =&gt; getenv('DB_SCHEMA'),
    'tablePrefix' =&gt; getenv('DB_TABLE_PREFIX'),
    'port' =&gt; getenv('DB_PORT')
];
</code></pre>

<p>After:</p>

<pre><code>return [
    'driver' =&gt; getenv('DB_DRIVER'),
    'server' =&gt; getenv('DB_SERVER'), // changed
    'user' =&gt; getenv('DB_USER'),
    'password' =&gt; getenv('DB_PASSWORD'),
    'database' =&gt; getenv('DB_DATABASE'), // changed
    'schema' =&gt; getenv('DB_SCHEMA'),
    'tablePrefix' =&gt; getenv('DB_TABLE_PREFIX'),
    'port' =&gt; getenv('DB_PORT')
];
</code></pre>

CC BY-SA 4.0
2018-10-25T09:03:02.710Z
Remember to add the file to .gitignore...
Clive Portman
CC BY-SA 4.0
2020-09-30T15:36:53.267Z
Thanks for this! Bloody Hyperlane changing these env variables... cost me ages.
Jay
CC BY-SA 4.0
2018-10-24T07:30:32.847Z
2018-10-24T07:36:46.417Z
2018-10-24T07:36:46.417Z
Clive Portman
<p>I'm trying out the recommended Hyperlane hosting with Craft CMS. After installing on Hyperlane, I then clone the repo on to my local machine and run 'composer install'. That runs fine, and I create a .env file with my db connection details in it.</p>

<p>What happens next is I go to install on my machine by viewing the admin panel but I get the following:</p>

<pre><code>Database Connection Error – craft\errors\DbConnectException
Craft CMS can’t connect to the database with the credentials in config/db.php.
↵
Caused by: Invalid Configuration – yii\base\InvalidConfigException
Connection::dsn cannot be empty.
in C:\Users\clive\OneDrive\Desktop\repos\projectname\vendor\yiisoft\yii2\db\Connection.php at line 602
</code></pre>

<p>If I add the database details to config/db.php myself, it works fine. It just seems to be a problem with fetching them from .env.</p>

<p>I'm using WAMP on Windows and have numerous Craft 3 projects already running. This same project is fine if I install locally from scratch. It's just when I start by cloning from Hyperlane.</p>

<p>Any ideas?</p>

<craft3><database><config>
Working locally after cloning Craft 3 from Hyperlane
# Working locally after cloning Craft 3 from Hyperlane

(Asked by: username_0 on 2018-10-23)

I'm trying out the recommended Hyperlane hosting with Craft CMS. After installing on Hyperlane, I then clone the repo on to my local machine and run 'composer install'. That runs fine, and I create a .env file with my db connection details in it.
What happens next is I go to install on my machine by viewing the admin panel but I get the following:
Database Connection Error – craft\errors\DbConnectException
Craft CMS can’t connect to the database with the credentials in config/db.php.
↵
Caused by: Invalid Configuration – yii\base\InvalidConfigException
Connection::dsn cannot be empty.
in C:\Users\clive\OneDrive\Desktop\repos\projectname\vendor\yiisoft\yii2\db\Connection.php at line 602

If I add the database details to config/db.php myself, it works fine. It just seems to be a problem with fetching them from .env.
I'm using WAMP on Windows and have numerous Craft 3 projects already running. This same project is fine if I install locally from scratch. It's just when I start by cloning from Hyperlane.
Any ideas?

**Tags:** craft3, database, config


---

## 1 answers

### Answer by username_0 on 2018-10-24. Score: 4 | Accepted answer

Solved. The config/db.php cloned from Hyperlane refers to different env variable names than those used within my .env file. Changing the names in config/db.php solved the issue.
Before:
return [
    'driver' => getenv('DB_DRIVER'),
    'server' => getenv('DB_HOST'),
    'user' => getenv('DB_USER'),
    'password' => getenv('DB_PASSWORD'),
    'database' => getenv('DB_NAME'),
    'schema' => getenv('DB_SCHEMA'),
    'tablePrefix' => getenv('DB_TABLE_PREFIX'),
    'port' => getenv('DB_PORT')
];

After:
return [
    'driver' => getenv('DB_DRIVER'),
    'server' => getenv('DB_SERVER'), // changed
    'user' => getenv('DB_USER'),
    'password' => getenv('DB_PASSWORD'),
    'database' => getenv('DB_DATABASE'), // changed
    'schema' => getenv('DB_SCHEMA'),
    'tablePrefix' => getenv('DB_TABLE_PREFIX'),
    'port' => getenv('DB_PORT')
];

> **Comments:**
> **username_0**: Remember to add the file to .gitignore...  
> **username_1**: Thanks for this! Bloody Hyperlane changing these env variables... cost me ages.  

---

