A Multitenancy example project using Laravel 8 and Spatie Laravel Multitenancy package
app\Http\Kernel.php
'tenant.web' => [
\Spatie\Multitenancy\Http\Middleware\NeedsTenant::class, \Spatie\Multitenancy\Http\Middleware\EnsureValidTenantSession::class,
],
'tenant.api' => [
\Spatie\Multitenancy\Http\Middleware\NeedsTenant::class,
],
config/multitenancy.php
'enabled' => env('MULTITENANCY_ENABLED', false),
//...
app/Providers/RouteServiceProvider.php
$api = ['api'];
$web = ['web'];
if (config('multitenancy.enabled')) {
array_push($api, 'tenant.api');
array_push($web, 'tenant.web');
}
Route::prefix('api')
->middleware($api)
->namespace($this->namespace)
->group(base_path('routes/api.php'));
Route::middleware($web)
->namespace($this->namespace)
->group(base_path('routes/web.php'));
Clone reposository
git clone git@github.com:victoryoalli/superapp.git
Install PHP packages using composer
composer install
Install Javascript/Node packages using npm
npm install && npm run dev
Create a Database
superapp
Copy
.env.example
to.env
Final project code
git fetch
git checkout meetup
or
Final project code
git fetch
git checkout webinar