How does Acquia Dev Desktop create the connection to the database? I am using Acquia Dev Desktop 2 on my windows 10 PC in order to develop Drupal 8 websites.

As far as I know, every Drupal website requires a connection between its files and the database 
which is accomplished by using the following code in the setting.php file.

$databases = array(
  'default' =&gt; array(
    'default' =&gt; array(
      'database' =&gt; 'databasename',
      'username' =&gt; 'sqlusername',
      'password' =&gt; 'sqlpassword',
      'host' =&gt; 'localhost',
      'port' =&gt; '',
      'driver' =&gt; 'mysql',
    ),
  ), 
);


I downloaded Drupal 8 and I imported it in Acquia Dev Desktop 2 using the 
Import local Drupal site option.


  





  


The site is correctly imported and installed; a new database has been created.

I cannot see the above database connection code anywhere in the settings.php file.

I noticed, however, that the following code is added to the bottom of the setting.php file.

// &lt;DDSETTINGS&gt;

// Please don't edit anything between &lt;DDSETTINGS&gt; tags.

// This section is autogenerated by Acquia Dev Desktop.

if (isset($_SERVER['DEVDESKTOP_DRUPAL_SETTINGS_DIR']) &amp;&amp; file_exists($_SERVER['DEVDESKTOP_DRUPAL_SETTINGS_DIR'] . '/loc_sitename_dd.inc')) {
   require $_SERVER['DEVDESKTOP_DRUPAL_SETTINGS_DIR'] . '/loc_sitename_dd.inc';
}

// &lt;/DDSETTINGS&gt;


How does Acquia Dev Desktop 2 create the connection between the site's files and the database without using the common database connection code shown above?

When moving my website from the local development server (Acquia Dev Desktop) to a remote server, I must create a connection to the database. Is it safe to delete the code between the &lt;DDSETTINGS&gt; tags added by Acquia Dev Desktop 2*?
Thank you all for your help and point me to the right direction !

I will give a detailed explanation because i believe this will benefit plenty of people with common error as mine !

Acquia Dev desktop 2, while creating/importing you website, will create a hidden file (loc_your_site_dd.inc) within its folders where the database connection code is located and then it will refer to that file by adding at the bottom of your setting.php file, few lines of codes similar to:

// &lt;DDSETTINGS&gt; 

// Please don't edit anything between &lt;DDSETTINGS&gt; tags. 

// This section is autogenerated by Acquia Dev Desktop. 

if (isset($_SERVER['DEVDESKTOP_DRUPAL_SETTINGS_DIR']) &amp;&amp; file_exists($_SERVER['DEVDESKTOP_DRUPAL SETTINGS_DIR'] . '/loc_sitename_dd.inc')) {
require $_SERVER['DEVDESKTOP_DRUPAL_SETTINGS_DIR'] . '/loc_sitename_dd.inc'; 
} 

// &lt;/DDSETTINGS&gt;


Actually this is not a problem and this is how Acquia Dev desktop handle the database connection and other configuration codes.

However, if you are using Drush with your Drupal 8 website but you are using it from a Git Bash instead of using the built-in cmd inside Acquia Dev Desktop, you will be facing a problem similar to this one:

The drush command 'XXX' could not be executed. 
[error] Drush was not able to start (bootstrap) the Drupal database. 


The problem here is that Drush won’t be able to find the  which it was added to your sites settings.php file and so it will not be able to find a connection to the database and in result will display the above error.

SOLUTION:

The best solution here is to find the hidden file created by Acquia Dev Desktop which is usually in Windows is located at (*C:\Users\username.acquia\DevDesktop\DrupalSettings*) and copy and pasted all of its contents to your settings.php file and then from inside the settings.php file, delete the code  codes added by Acquia Dev desktop.

Doing so, now Drush will be able to find a connection to the database and all will be working as expected.