PHP code example of buildrr / multisite

1. Go to this page and download the library: Download buildrr/multisite library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

buildrr / multisite example snippets


composer 


/**
 * Configure paths IR__ . '/paths.php';

/**
 * Get multisites
 */

"scripts": {
    "post-install-cmd": "App\\Console\\Installer::postInstall",
    "post-autoload-dump": [
        "Cake\\Composer\\Installer\\PluginInstaller::postAutoloadDump",
        "BuildrrMultiSite\\Console\\AutoLoader::postAutoloadDump"
    ]
},

'App' => [
	'paths' => [
		'templates' => [
			ROOT . DS . SITE_DIR . DS . 'vendor' . DS . '%s' . DS . 'src' . DS . 'Template',
			ROOT . DS . SITE_DIR . DS . 'src' . DS . 'Template' . DS,
			APP . 'Template' . DS,
			CORE_PATH . 'src'. DS . 'Template' . DS
		],
	],
],

// near the top of the file, outside of class AppView()

use BuildrrMultiSite\View\MultisiteView;

// inside of class AppView()
/**
 * Overwrites Cake/View::_paths()
 *
 * @param null $plugin
 * @param bool $cached
 * @return mixed
 */
protected function _paths($plugin = null, $cached = true)
{
	$multisite = new MultisiteView();
	$multisite->theme = $this->theme;
	return $multisite->_paths($plugin, $cached);
}


/**
 * Map domains this install will support, to where that site's files are located.
 * The incoming request domain is on the left, the folder within the sites
 * directory that the request maps to is on the right.
 */

$domains['example.com'] = 'example.com';
$domains['example-app.com'] = 'example-app-folder';

/**
 * find the folder that is being requested by the domain
 */
if (!empty($domains[$_SERVER['HTTP_HOST']])) {
    if (!defined('SITE_DIR')) {
        // this is the site combined local and remote sites directory
        define('SITE_DIR', 'sites/' . $domains[$_SERVER['HTTP_HOST']]);
    }
}

// APP/composer.json

"autoload": {
    "psr-4": {
        "App\\": "src",
        "BuildrrMultiSite\\": "./SITE_DIR/vendor/buildrr/multisite/src"
    }
},

composer dump-autoload