A full-featured multi-tenant app with Laravel Part 1 β€” Setup

Ashok Gelal
6 min readDec 10, 2017
Photo by Augustin de Montesquiou on Unsplash

Part 0, Part 1 πŸ‘‡, Part 2, Part3, Part4, Part 5, Part 6, Part 7

In this part we’ll accomplish the following tasks:

βœ… Create a project

βœ… Setup a system database and a user

βœ… Install and configure multi-tenant package

βœ… Add an artisan command to create a tenant

βœ… Add an artisan command to delete a tenant

1. Create a new Laravel project

Let’s get started by actually creating a new Laravel project. This is easy:

$ laravel new townhouse

2. Set up a system database

Just like with most any other web apps, townhouse is going to need a database and a database user. But unlike most other web apps this database user is going to be a bit different. Because our app will create 1 database for each tenant, our database user needs special privileges to do so.

Note: The following step for creating a database and a user is only applicable to MacOS+SequelPro users but you should be able to perform these on your choice of OS and your choice of MySQL client in the similar fashion.

--

--

Ashok Gelal

Learner. Achiever. Loves writing clean code and craft beautiful products. πŸ‘‰ https://alpas.dev