Saturday, January 4, 2020

Configure XenForo 2 to use FTP adapter for external and internal data storage

XenForo 1 needs an add-on to use remote storage for data (useful in container environments) but XenForo 2 supports FTP out of the box. Just put something like these in config.php:

$config['fsAdapters']['data'] = function () {
    return new \League\Flysystem\Adapter\Ftp([
        'host' => 'ftp.domain.com',
        'password' => 'password',
        'username' => 'data',
    ]);
};
$config['externalDataUrl'] = function ($externalPath, $canonical) {
    return 'https://data.domain.com/' . $externalPath;
};

$config['fsAdapters']['internal-data'] = function () {
    return new \League\Flysystem\Adapter\Ftp([
        'host' => 'ftp.domain.com',
        'password' => 'password',
        'username' => 'internal_data',
    ]);
};