Laravel Passport and HynTenancy — Part 1

There are three main packages I was trying to get working together: Laravel, Tenancy, and Passport.Edit — This will work with Laravel 5.7 and HynMulti-tenant 5.3SeriesThis article is part of a SeriesPart 1 — Laravel Passport and HynTenancy←You are HerePart 2 — VueJS and Laravel APIPart 3 — Laravel Multi-Tenant TestingGoals include:Tenant-based API authenticationEach tenant has it’s own databaseEach tenant has a specific URL they connect toSupport for landing pageSeems easy right?.Well… there aren’t many resources that show how to best utilize these packages together.So for this demo I will be creating a small ticketing system..Once a user signs in they will see a list of tickets and will be able to CRUD operations on the tickets..The Front End will be Vuejs and it will talk to our Laravel API.Buckle up and hang onto your hats because we are going to cover it all right here.Also special thanks to Ashok Gelal for writing this series..It helped me tremendously early on trying to figure out the hynmulti-tenant package..Check it out!Full-featured multi-tenant Laravel app from scratchHave you ever wondered where to get started with writing a robust multi-tenant Laravel app?.Wondered how to organize…blog.usejournal.comHere are the docs for the other packages as well.API Authentication (Passport) – Laravel – The PHP Framework For Web ArtisansLaravel – The PHP framework for web artisans.laravel.comThe multi tenant saas toolkit for LaravelTenancy allows you to easily scaffold a multi-tenant SaaS platform on top of the Laravel framework.laravel-tenancy.comSetting up the environmentWe will be creating a REST API that will be consumed by a SPA..Web authentication will be used for signing into the SPA and it will pull data via authenticated API calls.This code is also hosted on github.sadnub/laravel-tenancy-passport-demoLaravel demo with Passport and Tenancy..Contribute to sadnub/laravel-tenancy-passport-demo development by creating an…github.comGo ahead and install a tenancy compatible database (MySQL, MariaDB, or Postgre) and get PHP and a web server working..(Not covering that here).Install Laravel and packagesThe hyn/multi-tenant package won’t auto-discover unless the ‘system’ database driver is present..Just copy a connection that is there in config/database.phpand rename it system..I used the mysql connection.Publish necessary configuration files and scaffoldingAdd this line to your AppProvidersAppServiceProvider.phpThen run the following commands to publish the necessary configuration files and migrations.Setup environment variablesGo ahead and set the environment variables to match your setup.. More details

Leave a Reply