Get started with Laravel and Postgres using Supabase.

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
today we are looking at larel now larell is a PHP framework for building web applications as you can see some uh big names do like it um and it is quite interesting because um you know it's quite versatile so you can uh use it as kind of a headless back end as well for your you know react or view applications um or you can kind of Go full PHP um so there's a bunch of St kits and uh flavors uh and then there is uh a lot of batteries included and specifically around authentication authorization there is an um om included here uh database migrations and so a lot of um people like it for kind of you know the pretty much the batteries included uh part so I thought we can take a look at how we can use laravel with super base and the first thing that we need to do is just create a new laral project so we can use um composer just make sure that you have um PHP and composer installed on your machine and then what we can do is we can say uh composer create a new project uh laravel and we'll just call it super laral uh there we go and so now um we're getting kind of our application scaffolded now we'll go into our super laral and then you know if you know me I like to use um vs code and so you can see here now we have um a bunch of things scaffolded there's kind of some database factories and migrations so you can see here um there's a bunch of of migrations already in there for um the authentication part for example so you know tracking kind of our uh users here password reset tokens and you know kind of all all that stuff so that's already included here then um you know there's routes um there our app here for example HTP get some controllers bunch of middleware for like authen indication cookies session so yes a lot of stuff we kind of get out of the box and now what we can do is we can then say PHP Artisan serf kind of in our folder and so we'll then get our application running on um Local Host here and now you can see that is just kind of a you know basic um welcome view I think if we're looking in here for example at the routes or basically just you know for um the rout which is returning um this welcome View and that will be here um [Music] in the public assets and then resources views and you can see here that is um a PHP blade kind of um sort of template here um and you can see there is a a bunch of stuff in there already for like Lo in and register but um you can see that kind of login register is currently not enabled um because we need to kind of choose sort of our um starter kit you know for authentication uh and so that here in the starter kit section we can see there's a couple of uh different St starter kits available for example um you know use it with like pure PHP so blade is kind of that uh template dialect there we can use react view uh even nextjs or you know pure kind of API uh things like that and now this um laral Breeze is kind of a a simple implic uh implementation of lal's authentication features and it actually already includes a login and registration as well as password reset uh email verification kind of all um that so a lot of things already included in um this stter kit so now first and of all we will need to uh composer require a leral preze here as a development dependency um so that we can then um kind of install um you know our template so then we can just install kind of the default stack here so that's the breeze stack um with blade so it uses light as the the blade templates um for the application front end so what we can do is we can just say um Bree install here and then you know you have all the kind of different options here to get the the scaffolding that you want so we'll just go with um Alpine now yes of course we want D mode support we'll just choose the default PHP unit here um and as you can see you know there's a lot of things kind of included um this was really easy just kind of stepping through okay great and so now that we have that installed um what we can see actually in our database migrations um that's still the same that's already included there but I think now if we go to views yeah you can see here now we have a bunch of additional views we got the login register um kind of all of that and in our homepage that was what um what was showing so if we now uh run our um serf command again and go back to our application here you can now see that we have the login and um register routes now obviously if I um were to say register or um if I were to say login um you know we get uh an error because we haven't uh obviously set up our database connection so that's what we need to do now so the way this works actually if we look into config here we can see there is um a database config and the database config uh actually reads from um the uh environment variables so uh you can actually you you know just um configure the database connections via the environment variables so postgress SQL is what we are um using with superbase as you know superbase um gives you a full postgress database every every superbase project has a full uh postest database and so we'll just need to say p PG SQL and then um the we can use the database URL here so if we go to the environment um variables we can see okay instead of MySQL we'll want to use um postra SQL and then we can just set the database um URL instead of needing to set kind of all the different credentials if we don't have a superbase project yet we can go to database. new let's select my Thor webd orc here we'll just call it laravel now you can uh generate a database password uh here a secure one now important you will need need that database password later so you can just copy that and maybe um just put it in here for now database password now obviously you know this is a secret um password so don't expose that uh don't show it you know like I'm doing here and then we can just uh choose uh so I'm here in Singapore let's choose the closest location all right and now our project is ready we can go to database um well actually we can go to Project settings and then database and so you can see we can um get a connection string here so we'll just want you know um this is just you know if you're using impure uh PHP for example so here we are using um as you remember the database URL so we just want the URI option we can uh copy this here now if earlier you didn't copy your database password then you can reset your database password um so that you're able to put it in but if you copied it you can then just um put it into your connection string here so um yeah you can see this is your superbase project your password and then we're just connecting to um postgress SQL Okay so we can give that safe and so now that we have our connection string uh put in what we can run now is we can run the migrations um so as I mentioned um laravel has uh you know migrations um tooling built in so here we can see the migrations are already created for um you know our user management for our authentication uh and so what we can say is pH HP Artisan migrate and so you can see now we're running through the migrations and so now in our superbase project if we go to the tables we can see here that um we have a migrations table so we're keeping track of the migrations that were uh being run and um we have all the kind of other tables that are required here so for example our user table and so now that we've set that all up we can serve our application again and so now let's try um the login actually uh we will first need to register so let's register me here and we'll just create our um password login here register and so now you can see I am logged in uh and something that's really cool here as well is so they already have you know laravel has already kind of a profile page um in here um so we can delete our account we can update our password kind of update our profile information and so now if we go back to our database here you can see that the user was written to the database the password and all of that now um just note that this is not using superbase off uh but rather this is using you know the built laral authentication so that's why you're having this here on uh the public schema uh users if you remember if you're using superbase o um then you know it's using the O schema so in this case larell um you know is using its own o uh framework that's built into Taral so just kind of keep that in mind that here you're not um using super basol this is um pretty much all that you need to get started to use uh laravel with superbase uh it couldn't be easier than that um really you just need to set your database connection to pgsql which is supported by larl out of the box and then you just copy your database URL from the super base settings again project settings database here URI and you are ready to go now we'd love to see what you built with larel tweeted us at superbase and let us below let us know Below in the comments what you'd like to learn about next and I'll see you then [Music] bye-bye
Info
Channel: Supabase
Views: 1,822
Rating: undefined out of 5
Keywords: Laravel, supabase
Id: dg1suKt-7D4
Channel Id: undefined
Length: 12min 45sec (765 seconds)
Published: Wed Jan 17 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.