Playing
01. Introduction and demo

Transcript

00:00
Allowing your users to choose custom subdomains is actually pretty straightforward in Laravel. And in this course I'm going to guide you through how we set this up. We're going to do this within a Laravel Breeze app just because Laravel Breeze gives us the ability to update our profile information, gives us our authentication scaffolding and makes things a lot easier.
00:19
Although you can transfer anything in this course over to any Laravel app regardless of how you set it up. So let's take a look. I'm going to go over to the profile section here and I've added in this subdomain field. The moment I don't have one but I can go ahead and choose one.
00:34
Now of course this needs to be unique. Two users can't have the same subdomain and we can't have things like special characters in the subdomain either. We just want this to be plain text. So I'm going to go ahead and save this out and that's done.
00:48
I now have my own subdomain within this app. So I'm going to go ahead and get rid of profile on the end of here. I'm going to head straight over to alex. and then whichever domain that we're running our app on. If I go ahead and run this, sure enough we are now into my own area within this app.
01:06
So this is directly pulled from the database. We look the user up by their subdomain, pass that information down and now we can extract any information about that user that we want. We can also switch between pages within this specific domain and this is only valid for this domain. If we go back to our main app, it doesn't exist.
01:27
It just exists for any users that have added a subdomain. Now on the flip side of this, we're also going to disable any of the standard routes that we would find in our main app for any subdomains that we create. You can see that if we go over to slash dashboard on alex. and then the domain that we're using, it doesn't work. If we head back over to our main app, sure enough it does.
01:49
So although this is pretty simple to implement within Laravel, we're going to go through this step by step and talk about some of the issues that you might come up against. How to do this in the cleanest way possible. And at the end of the course, we're also going to deploy this so you can see how you can get this live and working for users in your app. Okay, let's head over to the next episode where we're going to set up a fresh app and get this subdomain column in the users table so we can start to allow users to choose their own subdomains.
9 episodes 31 mins

Overview

Allow users to choose their own subdomain, and give them their own area of your application where only their details are shown. You'll be able to register multiple routes for user areas.

Everything in this short course can be easily applied to your own applications where you need this functionality. We'll cover every step of the way, and some things to watch out for.

Finally, we'll learn how to deploy this and configure nginx and DNS records so you're ready to go.

Alex Garrett-Smith
Alex Garrett-Smith
Hey, I'm the founder of Codecourse!

Comments

No comments, yet. Be the first to leave a comment.