In my studio, we have successfully used multi-environment config files to allow several machines on our local network to use local MAMP installs as well as designate dev and production environments at our web host.
Locally we run sites on separate ports, so for instance to look at my site I point my browser to http://10.0.1.2:8081/. To look at what’s going on on each other’s machines in the studio, we just change the ip address.
But now we are looking to run both a stable “trunk” version and a “branch” version for developing new features of our site on each local machine. And I can’t see how to make that work in the general.php and db.php files.
The following is what I’ve had in general.php for running a single instance of the site on my server:
'10.0.1.2' => array(
'userSessionDuration' => false,
'environmentVariables' => array(
'siteUrl' => 'http://10.0.1.2:8081/',
'fileSystemPath' => ‘/path/to/trunk/files/‘,
),
),
I feel that what I’d like to do is something like the following to differentiate between the two sites running on 10.0.1.2:
'10.0.1.2:8081’ => array(
'userSessionDuration' => false,
'environmentVariables' => array(
'siteUrl' => 'http://10.0.1.2:8081/',
'fileSystemPath' => ‘/path/to/trunk/files/‘,
),
),
'10.0.1.2:8082’ => array(
'userSessionDuration' => false,
'environmentVariables' => array(
'siteUrl' => 'http://10.0.1.2:8082/',
'fileSystemPath' => ‘/path/to/branch/files/‘,
),
),
Similarly, in the db.php file, currently I’ve got:
'10.0.1.2' => array(
'server' => 'localhost',
'user' => 'root',
'password' => 'root',
'database' => 'trunk.database’
),
Which I thought I’d change to:
'10.0.1.2:8081’ => array(
'server' => 'localhost',
'user' => 'root',
'password' => 'root',
'database' => 'trunk.database’
),
'10.0.1.2:8082’ => array(
'server' => 'localhost',
'user' => 'root',
'password' => 'root',
'database' => ‘branch.database’
),
But alas these kick off this error:
An exception has been thrown during the rendering of a template ("Craft can’t connect to the database with the credentials in craft/config/db.php.") in "_layout" at line 15.
Am I trying to do something impossible, or can anyone point me in the right direction?
Thank you much, Willhaus
index.phpsince it's so nice to keep all your configs together in, duh,craft/config, but I'll take it if it works. I'll report back after I get a chance to test. – Willhaus Jul 24 '14 at 14:25fileSystemPathto define my whole separate branch install, allowing for not just separate templates, but plugins, etc also. Thx, and I'll report back if/when I get it working. – Willhaus Jul 24 '14 at 14:30environmentVariablesare nowhere as deeply integrated into Craft as you hope. These vars only work in "asset source settings" and "general settings" in the CP. – carlcs Jul 24 '14 at 15:11fileSystemPathtomyWebhostWantsMeToPutMyFilesHerePath, the var name is up to you! – carlcs Jul 24 '14 at 15:14An exception has been thrown during the rendering of a template ("Craft can’t connect to the database with the credentials in craft/config/db.php.") in "_layout" at line 15.error as before. You were referring to theindex.phpin the rot of the content folder, right? – Willhaus Jul 24 '14 at 16:20config/general.phpwould pay attention to the port,'fileSystemPath' => ‘/path/to/trunk/files/‘and'fileSystemPath' => ‘/path/to/branch/files/‘do a fine job of pointing to different sets of craft install files. – Willhaus Jul 24 '14 at 16:56craft.devsame machine,10.0.1.2network,craft.dyndns.orgexternal). – carlcs Jul 24 '14 at 19:04branch.willhaus.dev) and test new layout/features with these files. – carlcs Jul 24 '14 at 19:04