apsg / multisite
Package for laravel multisite feature (multiple installations)
Requires
- illuminate/support: ~5|~6
Requires (Dev)
- mockery/mockery: ^1.1
- orchestra/testbench: ~3.0
- phpunit/phpunit: ~7.0
- sempro/phpunit-pretty-print: ^1.0
This package is auto-updated.
Last update: 2024-11-19 05:28:58 UTC
README
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.
Installation
Via Composer
composer require apsg/multisite
Usage
After the installation:
Add your domain to your .env
file, i.e.:
MULTISITE_DOMAIN=test
Add view folder
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).
Config files and helpers
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');
Current domain helper
To check current domain use the Facade helper:
\Multisite::domain();
Multisite assets
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>
Testing
composer test
License
license. Please see the license file for more information.