Laravel Authentication Tutorial #1 - Intro & Setup
Skills:
Backend Performance60%
Key Takeaways
This video tutorial covers the setup and implementation of an authentication flow in a Laravel application, including project setup, environment configuration, and database management using tools like Laravel, Composer, and npm.
Full Transcript
hey there gang and welcome to your very first larl authentication tutorial okay then so in this series we're going to learn all about authentication in larl and we'll build a simple authentication system into a larl application from scratch in fact we're going to be building on the final project from the laravel beginner course I recently released and we're going to add authentication to that so that users can register they can log in log out Etc and we'll also be implementing authentication guards so that only authenticated users can view certain pages and even though you could use lell St kits to do all of this for you we're going to be building it from scratch because that way you'll learn a lot more about the whole authentication process now if you're completely new to larl then don't start here I would definitely suggest watching my laral beginners course first of all to get the basics then start this one and in that beginner's course you're going to learn how to make this ninja directory application which is going to serve as the starting point for this authentication course so definitely definitely check out that first of all if you need to the link is going to be down below this video and then come back to this course when you're done and you're going to learn how to add authentication to the project anyway that's what we're going to be building during the series and we'll get started on that in just a few minutes but first of all I want to quickly explain how a larl handles authentication using something called sessions so just a tiny little bit of theory first of all then we'll crack on with the code so like I just said authentication within laral applications is handled mainly through sessions now sessions are basically a way for the server to remember a user when they've logged in whereby larl creates a session ID for that user and it stores it on the server it also sends the same session ID back to the browser where it's stored in a session cookie thereafter the browser sends that cookie to the server on every following request it makes for example when a user tries to navigate to a different page or when a form gets submitted and the browser sends a post request to the server then on the server laral compares the session ID from the cookie with the session ID it stored on the server and by comparing those laral can deduce whether the use is authenticated or not now to facilitate this whole session based authentication flow larl provides us with a whole bunch of authentication tools and features out of the box and through these tools and features it makes implementing a robust authentication system incredibly easy okay then so now that a little bit of theory is out of the way let's crack on and set up the starter project which we're then going to add authentication to so you can download the starter project from this G Brio right here which I will leave the link to down below the video you just need to make sure that the starter project branch is selected from the branch drop down right here then click on the code button and download a zip folder of the project once you've done that you can unzip the project project folder and open it up in vs code also if you're using herd like I am to manage your LL applications make sure you put that project folder within the herd directory so it can be run and served up correctly and by the way you don't need to use this St project if you've already got your own that you want to work with that's completely fine because everything I'm going to cover in this series will translate to whatever Lara project you're working with also just really quickly before we open that stter project up I want to point out that I've created course files every single lesson in this series and you can view the code for each of those lessons by selecting the correct lesson from the branch dropdown once you've done that you can hit the code button again to download a zip folder of the code for that lesson or you can just browse right through it here anyway now we've downloaded that starter project let's unzip it and open it up all right so I've got this project open now in vs code and like I mentioned before I place this project folder inside the her directory on my computer so it can run properly I also renamed the project to ninjor Network or but you don't need to do that right then before we can preview this application in the browser we need to do a few things we need to install all the PHP dependencies using composer and all the frontend dependencies using npm we also need to set up the environment inside a EnV file and finally we need to create a database and run a migration to get all the default datas tables up and running so let's start with the first step which is to install all the project dependent depes now we're going to install the PHP dependencies using composer by opening up the terminal and you can just type composer install and then press enter and then once that's done we can clear down here and we're going to install all the front end dependencies by typing npm install and then pressing enter Okay so we've got all the dependencies installed now we can carry on with the next step which is to set up the environment by creating a EnV file within the root of the project so let's add that new file first of all and it's inside this file that we're meant to add configuration values like an app key which is used for encryption and hashing or database path Etc so we don't need to write all of this from scratch thankfully we've got another file called env. example which was generated by laravel and that contains a lot of this information and we just need to edit a few things inside it so we can open that example file up we can copy all of it and then we're going to go back to the file we just created and paste it all in now the first thing we're going to update in this file is the app URL because when we place a project in the her directory herd automatically creates a local URL for that project and that URL takes the form of your project folder name and then test at the end so since I renamed the project to ninjor network or which you can see right here at the top of the file tree I'm going to update the URL to that ninjor Network off and then test at at the end now if you're not using herd you can update this app URL to whatever setup you have okay so the next thing we need to update in here is the appcore key so that larel can use it and to get a value for the app key we can use Artisan so then first close the file and then open your terminal and you want to type PHP Artisan key and then a colon and then generat and this generates a key and it automatically assigns it to the appor key variable in the EnV file which is really nice all right so that's the next step done and the final bit of setup we need to do is to make a new database and run the migrations so then we're going to be using SQL light for this series that's a file based database which is good for playing around with and for small applications like the one we're making now to make a new SQL like database we just need to come to the databases folder and then create a new file then we should call that file database.sql light now this file name represents the default database that laral looked for without having to update anything in the EnV file if you named your database something else then you'll have to add a dbor database value to thatv file where the value is a path to that database file anyway we don't need to do that because we named it database.sql lights so the only thing left we need need to do now is run a migration to create all the project tables to do that we can open the terminal and type PHP Aran migrate and then we'll say-- seed to seed the tables with dummy data and then we're going to press enter once you've done that you should get some kind of success message and then if you open that new database file you're going to see those new tables right over here and by the way in order to view SQL light files like this you need to install a vs code extension called SQL lights viewer so make sure you install that as well okay then so all we need to do now is preview this project in a browser to do that we're going to run a command down here in the terminal which is npm run Dev and that means all the public assets like the CSS are going to be served up by vit for us all right and now we can just use that project URL in my case the one generated by herd to preview this in a browser okay then so this is what the stter project looks like we've got a welcome page and when we click on this button we get directed to a ninja listing page which is at for/ ninjas so we can see a bunch of these ninjas which are all coming from the database right here and we can click on one to see more about them we can also delete ninjas by clicking on the delete button and we can add new Ninjas by going to the create page and filling out this form right here which I'm not going to do right then so that is the starter project up and running in the next lesson we'll explore this a little bit more and then we'll start setting up the authentication routes and Views too like the register page and the login page by the way if you want to get access to the entire course now without YouTube adverts you can do it's right here on the net ninja. deev website so I'll leave the link to this page down below you can buy it now for just $2 right here or if you wanted to sign up for a net Ninja Pro subscription which is just $9 a month you'll get access to this course plus all of my other courses including all of the long masterclass courses as well again that's just $9 a month and the first month is half price using this promo code right here so like I say I'll leave this link down below otherwise my friends really hope you enjoy the series
Original Description
In this Laravel authentication course, you'll learn how to set-up and implement an authentication flow (sign up, log in & sign out) into a Laravel application.
🔥🔥 Get (early) access to the entire Net Ninja Pro library, including exclusive courses and masterclasses, here - https://netninja.dev/p/net-ninja-pro/
📂🥷🏼 Access the course files on GitHub:
https://github.com/iamshaunjp/laravel-auth
📂🥷🏼 Starter project on GitHub:
https://github.com/iamshaunjp/laravel-auth/tree/starter-project
🧠🥷🏼 Laravel 11 for Beginners:
https://www.youtube.com/watch?v=DKnn8TlJ4MA&list=PL4cUxeGkcC9gF5Gez17eHcDIxrpVSBuVt
🧠🥷🏼 PHP & MySQL Crash Course:
https://www.youtube.com/watch?v=pWG7ajC_OVo&list=PL4cUxeGkcC9gksOX3Kd9KPo-O68ncT05o
🔗🐄 Download & install Herd:
https://herd.laravel.com/
🔗👇 Laravel docs:
https://laravel.com/docs/11.x/readme
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from Net Ninja · Net Ninja · 0 of 60
← Previous
Next →
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Regular Expressions (RegEx) Tutorial #14 - Matching a Username
Net Ninja
Regular Expressions (RegEx) Tutorial #15 - Email RegEx Pattern
Net Ninja
Regular Expressions (RegEx) Tutorial #16 - Finishing Touches
Net Ninja
GraphQL Tutorial #1 - Introduction to GraphQL
Net Ninja
GraphQL Tutorial #2 - A Birdseye View of GraphQL
Net Ninja
GraphQL Tutorial #3 - Project (stack) Overview
Net Ninja
GraphQL Tutorial #4 - Making Queries (front-end preview)
Net Ninja
GraphQL Tutorial #5 - Express App Setup
Net Ninja
GraphQL Tutorial #6 - Setting up GraphQL
Net Ninja
GraphQL Tutorial #7 - GraphQL Schema
Net Ninja
GraphQL Tutorial #8 - Root Query
Net Ninja
GraphQL Tutorial #9 - The Resolve Function
Net Ninja
GraphQL Tutorial #10 - Testing Queries in Graphiql
Net Ninja
GraphQL Tutorial #11 - GraphQL ID Type
Net Ninja
GraphQL Tutorial #12 - Author Type
Net Ninja
GraphQL Tutorial #13 - Type Relations
Net Ninja
GraphQL Tutorial #14 - GraphQL Lists
Net Ninja
GraphQL Tutorial #15 - More on Root Queries
Net Ninja
GraphQL Tutorial #16 - Connecting to mLab
Net Ninja
GraphQL Tutorial #17 - Mongoose Models
Net Ninja
GraphQL Tutorial #18 - Mutations
Net Ninja
GraphQL Tutorial #19 - More on Mutations
Net Ninja
GraphQL Tutorial #20 - Updating the Resolve Functions
Net Ninja
GraphQL Tutorial #21 - GraphQL NonNull
Net Ninja
GraphQL Tutorial #22 - Adding a Front-end
Net Ninja
GraphQL Tutorial #23 - Create React App
Net Ninja
GraphQL Tutorial #24 - Book List Component
Net Ninja
GraphQL Tutorial #25 - Apollo Client Setup
Net Ninja
GraphQL Tutorial #26 - Making Queries from React
Net Ninja
GraphQL Tutorial #27 - Rendering Data in a Component
Net Ninja
GraphQL Tutorial #28 - Add Book Component
Net Ninja
GraphQL Tutorial #29 - External Query File
Net Ninja
GraphQL Tutorial #30 - Updating Component State
Net Ninja
GraphQL Tutorial #31 - Composing Queries
Net Ninja
GraphQL Tutorial #32 - query variables
Net Ninja
GraphQL Tutorial #33 - Re-fetching Queries
Net Ninja
GraphQL Tutorial #34 - Book Details Component
Net Ninja
GraphQL Tutorial #36 - Styling the App
Net Ninja
GraphQL Tutorial #35 - Making a Single Query
Net Ninja
Build Apps with Vue & Firebase - Udemy Course
Net Ninja
Updated Vue & Firebase Course (Udemy)
Net Ninja
Vue & Firebase Real-time Chat (Preview) #1 - Intro
Net Ninja
Vue & Firebase Real-time Chat (Preview) #2 - Project Structure
Net Ninja
Vue & Firebase Real-time Chat (Preview) #3 - Firestore Setup
Net Ninja
Vue & Firebase Real-time Chat (Preview) #4 - Welcome Screen
Net Ninja
Vue & Firebase Real-time Chat (Preview) #5 - Props in Routes
Net Ninja
Vue & Firebase Real-time Chat (Preview) #6 - Route Guards
Net Ninja
Vue & Firebase Real-time Chat (Preview) #7 - Chat Window
Net Ninja
Vue & Firebase Real-time Chat (Preview) #8 - New Message Component
Net Ninja
Object Oriented JavaScript Tutorial #1 - Introduction
Net Ninja
Object Oriented JavaScript Tutorial #2 - Object Literals
Net Ninja
Object Oriented JavaScript Tutorial #3 - Updating Properties
Net Ninja
Object Oriented JavaScript Tutorial #4 - Classes
Net Ninja
Object Oriented JavaScript Tutorial #5 - Class Constructors
Net Ninja
Object Oriented JavaScript Tutorial #6 - Class Methods
Net Ninja
Object Oriented JavaScript Tutorial #7 - Method Chaining
Net Ninja
Object Oriented JavaScript Tutorial #8 - Class Inheritance
Net Ninja
Object Oriented JavaScript Tutorial #9 - Constructors (under the hood)
Net Ninja
Object Oriented JavaScript Tutorial #10 - Prototype
Net Ninja
Object Oriented JavaScript Tutorial #11 - Prototype Inheritance
Net Ninja
More on: Backend Performance
View skill →Related Reads
📰
📰
📰
📰
10th Anniversary of the Excelize Open Source, New ersion 2.11.0 Released
Dev.to AI
TCP vs UDP, Explained — Part 1: Building a TCP Server in C++
Medium · Programming
The Session ID That Wouldn't Stop Changing
Dev.to · Michał Iżewski
Stop Data Leaks: Tenant Scopes in Laravel 🛡️
Dev.to · Prajapati Paresh
🎓
Tutor Explanation
DeepCamp AI