I am attempting to get multisite working, and am getting various errors - I’m sure its something small, but I can’t see to quite pin down what it is.
I have a site set up in grav/user/sites/www. To test it I access it via www.localhost, using Chrome.
The setup.py file contains the following:
<?php
use Grav\Common\Utils;
// Get subsite name from sub-domain
$environment = isset($_SERVER['HTTP_HOST'])
? $_SERVER['HTTP_HOST']
: (isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : 'localhost');
$environment = strtolower(Utils::substrToString($environment, ':'));
$subdir = current(explode('.', $environment));
$dir = "user/sites/{$subdir}";
if ($environment === 'localhost' || !is_dir(ROOT_DIR . "{$dir}")) {
return [];
}
return [
'environment' => $environment,
'streams' => [
'schemes' => [
'user' => [
'type' => 'ReadOnlyStream',
'prefixes' => [
'' => ["{$dir}"],
]
]
]
]
];
I have confirmed that $dir is correct when testing.
When I attempt to access the www subdomain, I get the “Issues Found” page with errors such as “grav/user/data does not exist” for the data, pages, plugins and themes subdirectories.
I tried explicitly specifying them by returning the streams, as follows:
return [
'environment' => $environment,
'streams' => [
'schemes' => [
'user' => [
'type' => 'ReadOnlyStream',
'prefixes' => [
'' => ["{$dir}"],
]
],
'accounts' => [
'type' => 'ReadOnlyStream',
'prefixes' => [
'' => ["{$dir}/accounts"],
]
],
'config' => [
'type' => 'ReadOnlyStream',
'prefixes' => [
'' => ["{$dir}/config"],
]
],
'pages' => [
'type' => 'ReadOnlyStream',
'prefixes' => [
'' => ["{$dir}/pages"],
]
],
'plugins' => [
'type' => 'ReadOnlyStream',
'prefixes' => [
'' => ["{$dir}/plugins"],
]
],
'themes' => [
'type' => 'ReadOnlyStream',
'prefixes' => [
'' => ["{$dir}/themes"],
]
]
]
]
];
However, this throws an exception: implode(): Invalid arguments passed