$30 off During Our Annual Pro Sale. View Details »

A practical look at multitenancy in Laravel

A practical look at multitenancy in Laravel

Freek Van der Herten

September 16, 2020
Tweet

More Decks by Freek Van der Herten

Other Decks in Programming

Transcript

  1. A practical look at
    multitenancy in Laravel

    View Slide

  2. About me
    Freek Van der Herten
    @freekmurze
    spatie.be
    ohdear.app
    flareapp.io

    View Slide

  3. spatie.be/open-source

    View Slide

  4. spatie.be/videos

    View Slide

  5. spatie.be/videos

    View Slide

  6. Multitenancy
    in Laravel

    View Slide

  7. What is multitenancy?
    A single application that serves several (groups of) users
    Users/teams cannot see data of other users/teams
    Multiple approaches: single database, multiple databases
    Tom Schlick at Laracon US: youtube.com/watch?v=T-gHOXFpZvg

    View Slide

  8. spatie.be/docs/laravel-multitenancy

    View Slide

  9. spatie/laravel-multitenancy
    1. Determine which tenant should be made current
    2. Dynamically change configuration when switching tenant
    3. Light tooling for migrations and running artisan commands

    View Slide

  10. Multi DB Demo
    & Source Dive

    View Slide

  11. Laravel Multitenancy
    A lightweight package
    Adapt to your own needs
    Single and multiple databases strategies
    spatie.be/docs/laravel-multitenancy
    github.com/spatie/laravel-multitenancy#alternatives

    View Slide

  12. Do you really need a package for multitenancy?
    Multitenancy seems daunting, but can be simple
    Take care of it yourself
    Steal the implementation of the package
    One less dependency to worry about

    View Slide

  13. One more thing…

    View Slide

  14. Do you ever work on client projects?

    View Slide

  15. Mostly very large ones that take months or years to complete
    laravel-multitenancy, laravel-event-sourcing, laravel-view-models, …
    Good way of building larger than average apps

    View Slide

  16. laravel-beyond-crud.com

    View Slide

  17. laravel-beyond-crud.com
    Book + premium video course
    A way of building large maintainable Laravel apps
    Many principles applicable to smaller projects as well
    25% discount: THANKS-FOR-WATCHING-PHP-LONDON

    View Slide

  18. laravel-beyond-crud.com
    25% discount: THANKS-FOR-WATCHING-PHP-LONDON
    Valid for two weeks
    Works for everything listed at spatie.be/products

    View Slide

  19. Thank you!
    spatie.be/docs/laravel-multitenancy
    freek.dev/1661-multitenancy-in-laravel
    spatie.be/products
    ohdear.app

    View Slide