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.
PHP:
$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. example.com and example.com/test).
PHP:
$config['cookie'] = array(
'prefix' => 'test_',
'path' => '/',
'domain' => ''
);
Change test_ as required.


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


Change the colour of the ACP to make it easy to differentiate from the production site.
PHP:
$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 ... 🤦
PHP:
 $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;.
PHP:
$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.
PHP:
$c['session.admin'] = function (\XF\Container $c)
{
    $session = new \XF\Session\Session($c['session.admin.storage'], [
        'cookie' => 'session_admin',
        'lifetime' => 86400
    ]);
    return $session->start($c['request']);
};
Change the value 86400 in seconds as required.


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


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