phpdotenv with multi-lang Craft setup on MAMP I inherited a Craft site which uses phpdotenv (which I'm unfamiliar with) and which I now have to make multi-lingual (https://craftcms.com/docs/localization-guide) with an added es and fr locale on top of the english language site.
The question is regarding the setup on MAMP which seems to never find the .env file.
On my production server in /es/index.php this works:

// Composer autoload
require_once('../../vendor/autoload.php');

// DotEnv
try {
    $dotenv = new Dotenv\Dotenv('../../');
    $dotenv-&gt;required(['DB_HOST', 'DB_NAME', 'DB_USER', 'DB_PASS']);
} catch (Exception $e) {
    exit('Could not find a .env file.');
}

// Path to your craft/ folder
$craftPath = '../../craft';

// Tell Craft to serve the spanish content
define('CRAFT_LOCALE', 'es');


However, the same code on my local MAMP install will not find the .env file no matter what path I enter into the new dotenv statement....
Anyone have any idea or suggestion? Truly stumped here.
Some troubleshooting steps:


Make sure a vendor/ folder exists two levels up from es/. If not, you need to run composer install in your terminal from the directory that contains a composer.json file. (If you don’t have Composer installed, see its installation instructions.)
Make sure a .env file exists two levels up from es/. It probably won’t, as you’re not supposed to include your .env file in the Git repo. You can copy it from production, or from .env.example if that exists. Then fill it in with working credentials for your local environment.


Matt Stauffer wrote a great article explaining how to get phpdotenv running with Craft 2: https://mattstauffer.com/blog/environment-specific-configuration-for-craftcms-using-phpdotenv/ Probably a good idea to read through that just to get an idea of how it’s all supposed to work (and what the advantages are).