ryancramerdesign / ProcessWire

Our repository has moved to https://github.com/processwire – please head there for the latest version.
https://processwire.com
Other
727 stars 198 forks source link

Multiple-site support simplified - site administrator can define path to Wire, Site and Config files #792

Open klor opened 10 years ago

klor commented 10 years ago

Re. Multiple-site support: My ProcessWire sites are hosted in an environment where I can administer multiple websites (one folder per site). I would like ProcessWire to be able to run from any (private) folder that each website can call; without having to set up symlinks. The purpose is to simplify the setup of each website installation.

For example, my applications can be named as follows:

_processwireapp

_wwww_foocom

_wwww_barcom

For inspiration on how other frameworks / CMS systems include application and config files, see also:

ryancramerdesign commented 10 years ago

While I've not tested it here, I think that PW should let you do that. Though you will have to adjust a few of the path settings in the ProcessWireBootConfig() method in the index.php file. But it is perfectly fine to modify the index.php file. It is fine to treat index.php as a site configuration file of sorts in this manner, as it's at your discretion whether to replace it through upgrades (the index.php file rarely changes across PW upgrades).

klor commented 10 years ago

I took a quick look into this. This change request require that the administrator can set ProcessWire variables in index.php or any other dispatch file. The variables to be modified in index.php seems to be:

    // ProcessWireBootConfig()
    $siteDir = 'site'; 
    $wireDir = 'wire';

Trouble is that PW uses relative paths in index.php ("site/...) which makes configuration of $configFile hard:

    include("$rootPath/$wireDir/config.php");
    $configFile = "$rootPath/$siteDir/config.php";
    $configFileDev = "$rootPath/$siteDir/config-dev.php";

For this reason it is not possible to "prefix" the Site and Wire directory paths with an absolute ("/www/foo_app/site/") or relative path ("../foo_app/site/").