How to duplicate a live site to use as a test site

How to duplicate a live site to use as a test site

Here are some useful src/config.php switches for a test site.

Refer to the manual for more information and other switches.

The first two switches I would consider to be essential for a test site.

Disable outgoing email.
$config['enableMail'] = false;

Set a different cookie prefix to avoid interfering with the production site if the test site is on the same domain (e.g. and
$config['cookie'] = array(
'prefix' => 'test_',
'path' => '/',
'domain' => ''
Change test_ as required.

Disable two factor authentication.
$config['enableTfa'] = false;

Change the colour of the ACP to make it easy to differentiate from the production site.
$config['adminColorHueShift'] = 250;
Change the value 250 as required.

Set the Board URL and disable the canonical setting which can cause issues with being redirected to the production site without realising and inadvertently changing settings or even uninstalling add-ons ... 🤦
 $c->extend('options', function(\ArrayObject $options)
    $options->boardUrl = 'https://localhost/xf';
    $options->boardUrlCanonical = false;
    return $options;
Change https://localhost/xf as required.

Write emails to a file (.eml) on the server - works with email disabled using $config['enableMail'] = false;.
$c->extend('mailer.transport', function()
    return \XF\Mail\Mailer::getTransportFromOption('file', [
        'path' => \XF::getRootDirectory() . '/_temp'
Change the directory _temp as required.

Extend the admin session time.
$c['session.admin'] = function (\XF\Container $c)
    $session = new \XF\Session\Session($c[''], [
        'cookie' => 'session_admin',
        'lifetime' => 86400
    return $session->start($c['request']);
Change the value 86400 in seconds as required.

Enable debug mode.
$config['debug'] = true;

Enable development mode.
$config['development']['enabled'] = true;
Top Bottom