EDITED: To refine question following further researcha and lack of response.
I am using grav on two sites now (family blog and my site), and possibly a friend’s business site soon too.
I develop locally on my Windows computer. As I don’t have SSH or Git access with my webhost (nor will I with my friend’s separate webhost), I do my edits locally and then manually upload the user/
folder to my webhost with Mozilla (sigh).
I currently use separate installs of Grav for each site, but this means I have to jump around between them to get to their respective user/
folders, then fire up their php servers and also fire up sass.
To speed things up, I’d ideally like to:
- Go to one place and start up (server and sass scripts) and use my editor to the relevant site’s user folder and start editing.
- Have access to each site’s admin as I want to extend that and so want to see if it works.
- When done, I can then simply grab the relevant site’s
user/
folder and upload it with Mozilla to the relevant webhost.
This seems to me like a good use case for a local multisite-setup.
Questions:
- Is this a good use case for Multisite?
[If so] - Any gotchas/considerations? [ e.g. memory killer / slow <= I’m on an 6 year old laptop but this is only for local dev ]
- How to set it up setup?
3.1 Do I do any edits to the subdirectory script below (happy with subfolders off localhost 8000)?
3.2 Or do I leave this as is, and just rename the sites’suser/
folders likeuser_site1/
,user_site2/
?
3.3 Or do I simply drop the script in root, without renaminguser/
folders, and it will create paths
local-grav-multisite-root/setup_subdirectory.php
<?php
/**
* Multisite setup for sub-directories or path based
* URLs for subsites.
*
* DO NOT EDIT UNLESS YOU KNOW WHAT YOU ARE DOING!
*/
use Grav\Common\Filesystem\Folder;
// Get relative path from Grav root.
$path = isset($_SERVER['PATH_INFO'])
? $_SERVER['PATH_INFO']
: Folder::getRelativePath($_SERVER['REQUEST_URI'], ROOT_DIR);
// Extract name of subsite from path
$name = Folder::shift($path);
$folder = "sites/{$name}";
$prefix = "/{$name}";
if (!$name || !is_dir(ROOT_DIR . "user/{$folder}")) {
return [];
}
// Prefix all pages with the name of the subsite
$container['pages']->base($prefix);
return [
'environment' => $name,
'streams' => [
'schemes' => [
'user' => [
'type' => 'ReadOnlyStream',
'prefixes' => [
'' => ["user/{$folder}"],
]
]
]
]
];
Any example scripts for localhost to differentiate between the site’s user/
folders (`e?
Hope this makes sense.
Thanks