Package for managing multiple installations of the same code base. It gives the ability to change the views depending on the "domain" but preserving the backend core the same.
It also lets you to define domain-specifig config.
Via Composer
composer require apsg/multisite
After the installation:
MULTISITE_DOMAIN=test
Create new view folder for your domain:
mkdir resources/views/test
And that's it! From now on the Laravel's view engine would look for view files in main view directory (resources/views/
) as well as in domain-specific directory (resources/views/test
in the example above).
The package provides helper Facade through which one can access domain-specific configurations. One can publish default config file using:
php artisan vendor:publish --tag=multisite.config
The helper:
\Multisite::config('some.key');
would return config equivallent to:
config('multisite.{current_domain}.some.key');
To check current domain use the Facade helper:
\Multisite::domain();
To compile your assets in your webpack.mix.js
add something like that:
// ----- MULTISITE -----------------
let domains = [
'site1',
'site2'
];
for (let domain of domains) {
mix.js('resources/assets/js/' + domain + '.js', 'public/js', domain + '.js')
.sass('resources/assets/sass/' + domain + '.scss', 'public/css', domain + '.css');
}
This will search automatically for files resources/js/{domain}.js
and resources/sass/{domain}.scss
, compile them and move them to directories public/js/{domain}.js
and public/css/{domain}.css
respectively.
Then one can use helpers provided with this package to automagically load in your layout file only domain-related files:
<link href="{{ multisite_css() }}" rel="stylesheet">
<script src="{{ multisite_js() }}"></script>
composer test
license. Please see the license file for more information.