Define a dynamic 'basePath' environmental variable without the locale So in my general config file I've defined an environmental variable called basePath (as per the Environment-Specific Variables documentation). I'm using the getcwd() function to get the working directory.

return array(
    '*' =&gt; array(
        'environmentVariables' =&gt; array(
            'basePath' =&gt; getcwd(),
        )
    ),
);


I'm using this for a few reasons:


I work in an environment where many people can be working on the same project at the same time. So their local basePath is always different.
My different siteUrls for my setup use trailing locales in the url: 'siteUrl' =&gt; array( 'en' =&gt; 'http://www.website.com/', 'fi' =&gt; 'http://www.website.com/fi/' ). So when it comes to targeting environment-specific locales, things get messy.
$_SERVER['DOCUMENT_ROOT'] is ok locally, but fails on a live server.


So my problem is when using getcwd(), the locale is included in path. Is there a way to trim this out dynamically? 

Or is there a way to strip out the current locale from this path on-the-fly? rtrim(getcwd(),"fi") 

Maybe there is a more reliable way to get the working directory?
Check out craft-multi-environment; even if you don't use it, you might crib some of the ideas from it.

For instance, how the basePath is determined.