Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am trying to synchronize development between a Windows user (WAMP) and a Mac user (Regular Apache).

Windows User (me) Since I use IIS I need my port 80 so I have changed the ports on WAMP to :666.

So the url to the Wordpress is http://localhost:666/projectname/

Mac user He has the site on a non-alias, just the path the the project

So the url is http://localhost/foldername/wordpress/


In wp-config.php I have the following code

if (file_exists('local_settings.php')) {
include('local_settings.php');
} else {
$debug_on = true;
}

And in the local_settings.php

define('WP_HOME', 'http://' . $_SERVER['HTTP_HOST'] . '/projectname/');
define('WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST'] . '/projectname/');

But this code doesn't seem to actually override the damn stupid database siteurl because when he tries to login, it still heads to localhost:666 (which is the value in the database).

Or is it impossible to sync different developers? How do you guys do it? And please don't ask me to change my port to :80 :)

share|improve this question
    
Does HTTP_HOST include custom port? If not you will need to add this as needed. –  Rarst Dec 13 '11 at 18:22
add comment

3 Answers 3

up vote 1 down vote accepted

You need to have 2 sets of settings one for if file_exists and one for else:

if ( file_exists( dirname( __FILE__ ) . '/local-config.php' ) ) {
  include( dirname( __FILE__ ) . '/local-config.php' );
  define( 'WP_LOCAL_DEV', true ); 
} else {
  define('WP_HOME', 'http://localhost:666/projectname/');
  define('WP_SITEURL', 'http://localhost/foldername/wordpress/');
}
share|improve this answer
    
That sorted it out, thank you :) –  vlarsson Dec 13 '11 at 18:45
add comment

Edit: Ignore this answer.

The constants have already been defined. It's not possible to redefine constants in PHP.

Try including local_settings.php before the following line in wp-settings.php (instead of wp-config.php):

require(ABSPATH.WPINC.'/default-constants.php');

share|improve this answer
add comment

My team and I usually change the domain in the DB for each local environment.

You can do it manually or run a two liner in functions.php:

update_option('siteurl','http://localhost/foldername/wordpress');
update_option('home','http://localhost/foldername/wordpress');

You only have to run this update once in the Mac user's machine.

reference: http://codex.wordpress.org/Changing_The_Site_URL

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.