sprout-laravel/
sprout
g4t.io

Sprout Multitenancy Package for Laravel

18 views 366 stars by Paul Redmond

A flexible, seamless and easy to use multitenancy solution for Laravel

laravel laravel-multi-tenancy laravel-multi-tenant laravel-multitenancy laravel-package multi-tenancy multitenancy package
README from sprout-laravel/sprout Open on GitHub →

Packagist Version Packagist PHP Version Support

GitHub Laravel codecov

Unit Tests Static Analysis

Sprout for Laravel

A flexible, seamless, and easy to use multitenancy solution for Laravel

Sprout is a multitenancy package for Laravel that fits seamlessly into your application. It provides a whole host of features, with the flexibility to allow you to add your own. You can read all about Sprouts features and how to get started in the documentation.

Features

Sprout comes out of the box with the following features:

  • Tenant Identification: Sprout can identify tenants by subdomain, path, header, cookie or session. It can do this immediately once a route is matched, or during the middleware stack.
  • Multiple Tenancies: Sprout can handle multiple tenancies, as in multiple different models that are tenants.
  • Tenant Storage Disks: Sprout comes with a service override that allows you to create a storage disk that always points to the current tenant's storage directory.
  • Tenant Sessions & Cookies: If you're identifying tenants via a method that uses the URL (subdomain or path), cookies, and therefore the session cookie, will be automatically scoped to the current tenant.
  • Tenant Cache Stores: Just like with storage disks, Sprout allows you to create a cache store that always returns the current tenants cache.
  • Tenant Aware Jobs: When a job is dispatched, Sprout will make sure that any tenancies that are active are recreated when the job is processing, along with their current tenants.
  • Tenant Password Resets: If you're following a model where users belong to a single tenant, you'll also want to make sure that password resets are scoped to the tenant. Sprout can do this for you.
  • Automatic Scoping: As well as all the automated scoping of storage disks, cache stores, jobs, password resets and so on, Sprout also comes with a set of functionality for automatically scoping models, during creation and querying.

There are also three upcoming first-party addons for Sprout:

  • Sprout Bud: Bud allows you to manage tenant-specific configuration, with built-in support for dynamically configuring a whole of Laravels core connections and driver-based services.
  • Sprout Seedling: Seedling builds on-top of the functionality provided by Sprout Bud, to bring multi-tenant-specific database support to your Laravel application. As well as enabling the dynamic configuration of connections, it comes with a batch of supporting functionality to make managing tenant-specific databases easier.
  • Sprout Terra: Terra brings domain-based identification to Sprout, allowing you to identify tenants based on the domain they are accessing your application from. Just like with Seedling, it also comes with a bunch of supporting functionality for dealing with tenant domains.

FAQ

Does Sprout support tenant-specific databases?

It will do through Sprout Seedling, which is currently in development.

Why are tenant-specific databases handled by an addon?

I didn't want to just provide a barebones implementation of tenant-specific database handling, as there's a lot more to think about than just changing the connection on a model. So, I wanted to provide the feature with a bunch of opt-in supporting functionality, which is why it's an addon.

Does sprout support domain-based identification?

It will do through Sprout Terra, which is currently in development.

Why are domain-based tenants handled by an addon?

The same as with Seedling, I wanted to provide a bunch of supporting functionality to make managing domain-based tenants easier, which is why it's an addon.

Why should I use Sprout over other multitenancy packages?

It will mostly come down to preference, but I've tried to make Sprout as flexible as possible, without compromising on any features and functionality. It is built to be as seamless as possible, avoiding hacky workarounds and providing a clean API. No magic to dynamically modify things, or artificial limitations, whether side effects or not.

Why did you build Sprout?

I found that the existing multitenancy packages for Laravel were either too opinionated, not flexible enough, or lacking in features. I wanted to build something that was flexible, feature-rich, and easy to use.

More from the ecosystem

durable-workflow/
workflow
g4t.io
9 1,292

Durable Workflow: Long-Running Workflows for Laravel

Embedded durable workflow runtime and orchestration engine for Laravel applications.

durable-workflow/workflow via Laravel News
packstub/
session-replay
g4t.io
14 52

Session Replay for Laravel: Self-Hosted Browser Recordings

Session replay for Laravel: record what a person did in the browser with rrweb, keep the recording on your own disk and database, and watch it behind a gate you define — masked inputs by default, errors, failed Livewire requests and web vitals marked on the timeline, a link to the replay in every log line. packstub/filament-session-replay adds the sessions to a Filament panel.

packstub/session-replay via Laravel News
cyberwizard-dev/
schedule-catchup
g4t.io
17

Replay Missed Laravel Scheduled Tasks With Schedule Catchup

Schedule Catchup replays missed Laravel scheduled tasks after downtime, with opt-in recovery, bounded retries, and access to the original scheduled date.

cyberwizard-dev/schedule-catchup via Laravel News