Multitenancy
with Laravel

Learn how to build a multitenanted Laravel application that works the way you want, without all of the fuss.

Buy now

Sign up to the newsletter to get the first video, free.

Hi! My name is Ollie, and I'm a PHP developer, with a heavy focus on Laravel.

For the last 7 years, I've been working mostly with multitenanted SaaS applications. The thing is, I didn't know that at the time. I thought I knew what multitenancy was.

During my research for an article on the topic of multitenancy, I discovered two things;

I put this research to work and wrote the article, "Multitenancy with Laravel, avoiding over-engineering". A year after release, I noticed that there was still a lot of confusion and misunderstanding of the topic.

So, I started writing this course.

Don't overcomplicate

You know as well as I do that it's all too easy to finish a big project, only to realise that you have overcomplicated it. Multitenancy is no exception to this.

"There are lots of packages out there, why not just use one of those?"

I have found that a lot of the content out there, especially dealing with Laravel, doesn't quite cut it. That doesn't mean that it is bad, or wrong, it's just often incomplete.

There are two main problems that I have found.

The main aim of this course is to address both of these problems. I have spent a long time exploring as many options as I can, simplifying each way while still providing clean and tidy solutions.

Course

$199 $129 excl VAT

  • Reduced price for early birds
  • Access to videos as they're released
  • All future updates
  • All future additional material
  • 1080p download
  • View current content

Package

$199 excl VAT

  • Priced per site
  • Full feature parity with the course
  • Seamless implementation
  • Fully customisable
  • Composer repository access
  • All version 1 updates

What's inside

This course is split into chapters, with each one focusing on a category options and solutions, often providing different ways of doing the same thing. You pick the way that works for you.

Tenant Identification

You can identify a tenant using almost anything available in a standard HTTP request. This course covers 6 different ways of doing this, as well as covering the limitations and additional requirements of each approach.

Users

If you aren't using your application's users as tenants, you have a handful of options open to you. Whether you want globally shared users, tenant-specific users, or even a Slack style user system, this course has you covered.

Databases

There are several ways to set up a database for multitenancy, and the best method for you depends on the requirements of your app. Whether you need a single database, a database per tenant, or some combination of the two, this course shows you how to achieve that.

Further Features

A lot of the features you'll find in a multitenanted application won't be specific to multitenancy. There's also the need to configure Apache or Nginx to work with your new application. This course covers some further useful features and how to configure your HTTP server.

Laravel

Instead of just using parts of the framework, this course goes into detail about how the bits that you need work, and why you should use them. Laravels flexibility allows you to achieve multitenancy with the functionality provided.

Clean Code

I consider clean code to be an essential part of any codebase, and the code in this course is no exception. Instead of creating large classes with overly simplified code, I've made use of best coding practises to provide solutions that aren't overcomplicated, or over-abstracted.

Videos

This course is actively being worked on with videos being released in groups based on the topic(s) that they cover. Below is a list of current videos, updated as and when they're ready.

This list doesn't include all of the videos as some are added or reworked as the rest are completed.

  • Chapter 1 Getting Started

    This chapter is all about the initial setup, introducing the concept of multitenancy to the codebase, and building a foundation for the rest of the course.

    • 1.1

      Defining the tenant

      9m 56s
    • 1.2

      Loading the tenants using Eloquent

      13m 44s
    • 1.3

      The tenancy manager

      18m 48s
    • 1.4

      The tenancy facade

      Coming Soon
  • Chapter 2 The HTTP layer

    This chapter is all about the HTTP layer, including different methods of tenant identification as well as various pieces of supporting functionality.

    • 2.1

      Tenant route groups and middleware

      12m 30s
    • 2.2

      Identifying tenants by subdomain

      7m 12s
    • 2.3

      Identifying tenants by domain

      10m 15s
    • 2.4

      Identifying tenants using the URI

      Coming Soon
    • 2.5

      Identifying tenants using a HTTP header

      Coming Soon
    • 2.6

      Using the current user as a tenant

      Coming Soon
    • 2.7

      Using a relationship on the current user as the tenant

      Coming Soon
    • 2.8

      Identifying tenants using sessions or cookies

      Coming Soon
    • 2.9

      Generating tenants URLs

      7m 45s
    • 2.10

      Adding a fallback subdomain for tenant domains

      17m 02s
    • 2.11

      Verifying a tenants domain using DNS

      27m 11s
    • 2.12

      Generating SSL certificates for tenant domains

      Coming Soon
  • Chapter 3 The database

    This chapter is all about the database, from single shared databases to databases and credentials per tenant.

    • 3.1

      Shared tenant database

      19m 44s
    • 3.2

      Creating a dynamic tenant database connection

      Coming Soon
    • 3.3

      A database per tenant

      Coming Soon
    • 3.4

      Tenant specific database credentials

      Coming Soon
    • 3.5

      Migrating and seeding tenant databases

      Coming Soon
    • 3.6

      Dropping tenant databases

      Coming Soon
    • 3.7

      Overriding the config for each tenant using the database

      Coming Soon
  • Chapter 4 The core

    This chapter is all about making some of Laravels core components multitenanted.

    • 4.1

      Serialised models in jobs (queues)

      Coming Soon
    • 4.2

      Automatically prefixing the cache

      Coming Soon
    • 4.3

      Storing tenant sessions in the database

      Coming Soon
    • 4.4

      Tenant specific file storage

      Coming Soon
    • 4.5

      Storing tenant sessions on the filesystem

      Coming Soon
  • Chapter 5 Users & Authentication

    This chapter covers everything user and authentication based.

    • 5.1

      Tenant specific users

      Coming Soon
    • 5.2

      Global shared users

      Coming Soon
    • 5.3

      Tenant specific shared users (Slack)

      Coming Soon
  • Chapter 6 Everything else

    This chapter covers a whole range of topics that don't really fit into the other chapters.

    • 6.1

      Configuring Nginx for tenant subdomains and domains

      Coming Soon
    • 6.2

      Configuring Apache for tenant subdomains and domains

      Coming Soon
    • 6.3

      Generating Nginx server blocks for tenant domains

      Coming Soon
    • 6.4

      Feature locking tenants

      Coming Soon