config.php for development- and live servers

Talk about writing modules and plugins for CMS Made Simple, or about specific core functionality. This board is for PHP programmers that are contributing to CMSMS not for site developers
Post Reply
Andiministrator

config.php for development- and live servers

Post by Andiministrator »

In most cases of development with CMSms, the development takes place on a development server during a stable version runs on the live server. To transfer the whole project from the development- to the live server, you need to change the config.php every time. I did some changes on the config.php to use it in the same version on both, development- and live server.

At the first step I changed the database vars.

Code: Select all

$config['dbms'] = 'mysqli';
if ($_SERVER["SERVER_NAME"]=="LocalHostName" || $_SERVER["SERVER_NAME"]=="www.LocalHostName") {
	$config['db_hostname'] = 'LocalHostName';
	$config['db_username'] = 'LocalUserName';
	$config['db_password'] = 'LocalPassword';
	$config['db_name'] = 'LocalDBName';
	$config['dev'] = true;
} else {
	$config['db_hostname'] = 'RemoteHostName';
	$config['db_username'] = 'RemoteUserName';
	$config['db_password'] = 'RemotePassword';
	$config['db_name'] = 'RemoteDBName';
	$config['dev'] = false;
}
Here I use both database connections. In addition I use the var $config['dev'], to distinguish later on in modules, for example for log files, etc.

Within the next step I get the root url and the root path automatically.

Code: Select all

$config['root_url'] = "http://".$_SERVER["SERVER_NAME"];
if(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS']=='on')
{
$config['root_url'] = str_replace('http','https',$config['root_url']);
}

$config['root_path'] = $_SERVER["DOCUMENT_ROOT"];

The last step is to change all fixed pathes to dynamical pathes, for example:

Code: Select all

$config['previews_path'] = $config['root_path']."/tmp/cache";

Find the complete config.php attached.

What do you think, is there anything wrong with that?
Attachments

[The extension pdf has been deactivated and can no longer be displayed.]

nhaack

Re: config.php for development- and live servers

Post by nhaack »

This sounds really fancy... Will give it a try during the weekend... would really match my situation and make things much easier...

Thanks for sharing.

Best
Nils
Andiministrator

Re: config.php for development- and live servers

Post by Andiministrator »

I added the versions of config.php and .htaccess to a project:
http://dev.cmsmadesimple.org/projects/configms

I use this versions of config.php and .htaccess since 2008 without any problems.

Notice: This versions will activate user-friendly URLs (mod_rewrite).
Flyingknight
New Member
New Member
Posts: 3
Joined: Thu Aug 19, 2010 9:46 pm

Re: config.php for development- and live servers

Post by Flyingknight »

Thanks for the config.php file. I did not use it to connect to a Live server.. is for connect to a second database.
My problem is that I need to make changes to the login form because I need that the login module uses the data stored in another table in the second database for autentication. This table is different from the users table in the CMS.
How can change the variables in the "login.php"  to match with the "users" table in the second database for autentication? Need this because I have a database full with users info and I can´t ask to the members to register again in the CMS. The another table have a different name too.
Any help will be apreciated.

Thankyou

José
Last edited by Flyingknight on Mon Aug 23, 2010 5:49 am, edited 1 time in total.
Flyingknight
New Member
New Member
Posts: 3
Joined: Thu Aug 19, 2010 9:46 pm

Re: config.php for development- and live servers

Post by Flyingknight »

Any idea???

Wow I think that in this forum could find answers, but I was wrong, I'll try to find the answer myself.

Thanks anyway :-[
NaN

Re: config.php for development- and live servers

Post by NaN »

You're just in the wrong place.
This has nothing to do with a modified config.php (i guess).
Post Reply

Return to “Developers Discussion”