Multi-Environment Configs in CraftCMS 3 I am at the very early stages of using CractCMS but I'm keen to get off to the correct start, writing notes as I go along etc but I cannot figure this issue out.

I have setup the Multi-Environment Configs to allow me to use, dev, staging and production sites, staging and production appear to work correctly but development site is causing issues.

I know it's something to do with the .env file and

ENVIRONMENT="production"


If I change that to

ENVIRONMENT="dev"


The development site will work.

What I can't understand is, both staging and production work so why not development?

I thought by using db.php and general.php I could do away with .env? Other than this line I can.

Here's my General.php code

&lt;?php

return [
// Global settings
'*' =&gt; [
    // Default Week Start Day (0 = Sunday, 1 = Monday...)
    'defaultWeekStartDay' =&gt; 1,

    // Enable CSRF Protection (recommended)
    'enableCsrfProtection' =&gt; true,

    // Whether "index.php" should be visible in URLs
    'omitScriptNameInUrls' =&gt; true,

    // Control Panel trigger word
    'cpTrigger' =&gt; 'admin',


    // The secure key Craft will use for hashing and encrypting data
    'securityKey' =&gt; '*******************************',
],

// Dev environment settings
'dev' =&gt; [

    // Base site URL
    'siteUrl' =&gt; null,



    'basePath' =&gt; '@webroot/cpresources',

    'baseUrl'  =&gt; 'https://mydomain.test',
],

// Staging environment settings
'staging' =&gt; [
    // Base site URL
    'siteUrl' =&gt; null,

    'basePath' =&gt; '@webroot/cpresources',

    'baseUrl'  =&gt; 'https://staging.mydomain.co.uk',
],

// Production environment settings
'production' =&gt; [
    // Base site URL
    'siteUrl' =&gt; null,

    'basePath' =&gt; '@webroot/cpresources',

    'baseUrl'  =&gt; 'https://mydomain.co.uk',
],
];


Here's my db.php code

&lt;?php

return array(
'*' =&gt; array(
    'tablePrefix' =&gt; '',
    'driver' =&gt; 'mysql',
    'schema' =&gt; 'public',
),
'dev' =&gt; [
    // Base site URL
    'server' =&gt; 'localhost',
    'user' =&gt; 'myusername',
    'password' =&gt; '*************',
    'database' =&gt; 'mydatabasename',
],
'staging' =&gt; array(
    'server' =&gt; 'localhost',
    'user' =&gt; 'myusername',
    'password' =&gt; '*************',
    'database' =&gt; 'craft_cms_staging',
),
'production' =&gt; array(
    'server' =&gt; 'localhost',
    'user' =&gt; 'myusername',
    'password' =&gt; '*',
    'database' =&gt; 'craft_cms_production',
),
);


Now before anyone says anything about uploading db.php and general.php to git etc because of passwords, I have put both these files in the .gitignore file. I felt this was the best option but if I'm wrong, please explain?
For anyone interested, I had set web/index.php to production.

The reason why both staging and production were working was due to me using the same username and password for the database.

Once I had changed this to dev, it now works so I no longer need the .env file.