Im currently using a 2 server workflow with modx, dev.mymodxsite.com with its own database, and mymodxsite.com with its own database for production (live site).
when functionality and content is approved on dev, we then move it to the production site.
each time we do this there are a number of places that need to be edited so that all the paths and databases match up.
I am looking to speed workflow using modx in a dev/production workflow by altering the config file to use different settings based on the url, and so far have the following to PHP added to my config file to toggle database names:
$devdomain = "dev.mymodxsite.com";
if ( strcmp($_SERVER["HTTP_HOST"],$devdomain) == 0 ) {
$dbase = ’devdatabase’;
}else{
$dbase = ’database;
}
what im looking to do is also hard code the $base_path variable so that fckEditor etc. point to a different directory for each instance of dev vs. stage.
but no matter what i try, defining the $base_path variable in the config file is always ignored.
does anyone have any ideas that may help?
-
MODX Staff
- 10,725 Posts
base_path is dynamically determined. dbase is not. simply edit the dbase in your config file between dev/prod
yeah, the code im using to switch database works, i just missed the ’ when removing the "real" variable values. (i didnt want to post my real values for obvious secirity reasons).
but in theory, I should be able to define the $base_path in the piece of code in the config file.
there is a function here that is supposed to "detect" the correct path if you leave the values in modx empty.
this seems like the natural place to do such a thing.
im looking to get my modx workflow in switching from "dev" to "production" file set and database as streamlined as possible, so pushing content live is like a flip of the switch, rather than editing config file, and file paths in modx tools.
[tt]$base_path[/tt], as well as many other variables are automatically calculated for every request. This is done in the [tt]manager/includes/config.inc.php[/tt] file below the comment line that reads [tt]// automatically assign base_path and base_url[/tt]. Everything after that comment line is the logic that determines [tt]$base_path[/tt], [tt]$base_url[/tt], and [tt]$site_url[/tt]. You’ll notice that it first tests if [tt]$base_path[/tt] or [tt]$base_url[/tt] are already not empty. The logic is skipped if the variables already exists.
Note that if you are going to explicitly define [tt]$base_path[/tt], you must also define [tt]$base_url[/tt], and [tt]$site_url[/tt].