processwire / processwire-requests

ProcessWire feature requests.
40 stars 0 forks source link

Include and Bootstrap with Multi-Domain Configurations #185

Open ethanbeyer opened 6 years ago

ethanbeyer commented 6 years ago

Short description of the enhancement

Include & Bootstrap is very awesome, but only allows targeting the '*' => 'site-normal' instance of ProcessWire installations that use the Multi-Site/Domain Config File (index.config.php)

Current vs. suggested behavior

If a single installation of ProcessWire has multiple sites/domains running from multiple site-* directories, the only site that is currently available is the default (*).

I propose that $site = new ProcessWire($config) take a secondary non-required argument that is the folder name (site-skyscrapers), in order to load that instance of ProcessWire.

Why would the enhancement be useful to users?

I can't be the only person using Multi-Domain setups - and making the API of each of those sites accessible is super valuable.

Toutouwai commented 6 years ago

Related forum topic: https://processwire.com/talk/topic/18661-bootstrap-multi-site-sites/

ethanbeyer commented 6 years ago

Ah, good find.

I think there has to be a way to do this, even if it requires writing a custom bootstrapping function as a part of ProcessWire.php. Being able to pass the Site Directory's name, or the path to the Site's config.php file are other options.

I'm going to take a stab at it and see if I can figure it out. May be way over my head, but it would solve a major problem for me if I could get it working!

ethanbeyer commented 6 years ago

Well, without modifying the core, I was able to get this to work:

include_once("./index.php");
$marketingConfig = \ProcessWire\ProcessWire::buildConfig('./', NULL, ['siteDir' => 'site-marketing']);
$mWire = new ProcessWire($marketingConfig);

This means that the default site will be available with $wire. An additional site, in the site-marketing directory, is available with $mWire.

This does come with a caveat, though: FormBuilder had to be uninstalled from both installations, because FormBuilderMain could only be declared once, and Tracy had to be uninstalled because it needed a defined log path.

I've spent a good portion of the day looking for a way to extend this functionality, but I may be too much of a greenthumb.