Different development environments (Mac & Windows)

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.

Read More

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 🙂

Related posts

Leave a Reply

3 comments

  1. 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/');
    }
    
  2. 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’);

  3. 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