Part 27 - Laravel Authentication Routes Views [How to Build a Blog with Laravel Series]

preview_player
Показать описание
The second segment in our collection of authentication tutorials for Laravel. In this video we will work on the routes and views necessary to set up the DEFAULT Laravel authentication system.

Routes:
By default Laravel does not set up routes for our authentication system. We need to do that ourselves. We need to set up two routes for logging in (post and get) and then we need to set up a get request for logging out. Finally a get and post request for registering a new user.

You will want to copy the code exactly as put in the code snippets section below.

Views:
We need to create only two views for our users. One is a form for logging in and the other is a form for registering a new user. You can really create any type of form you want, but make sure you follow the basic outline:

Form
CSRF Protection (automagically added when you use form helpers).
Email Field
Password Field
Remember Me Checkbox (will work without it, but won't be able to trigger remember functionality)
End Form

Coming Up:
We will be making the create() function working so we can fill out a form to make a blog post.

--- CODE SNIPPETS ---

// Authentication Routes

// Registration Routes

View this snippet on Github:

--- DOWNLOAD SOURCE CODE ---

--- LINKS ---

Laravel Form Helpers Documentation:

Laravel Docs for Authentication:

--- MORE FROM THIS SERIES ---

--- FOLLOW ME ---

Subscribe for New Releases!

(ask me questions!)

--- QUESTIONS? ---

Leave a comment below and I or someone else can help you.
For quick questions you may also want to ask me on Twitter, I respond almost immediately.

Thanks for all your support!

---

Tags: Routes and Views for Authentication with built in to Laravel 5.2 Framework Tutorial Easy to learn. Best tut about Laravel. Build a blog with Laravel Tutorial. Beginner tutorial. How to video. PHP framework easy best tutorial. Laravel 5 coding in PHP with Alex.
Рекомендации по теме
Комментарии
Автор

"php artisan make:auth" produces all the authentication scaffolding required for the authentication process.

sodomousprime
Автор

#MUST WATCH BY EVERYBODY WHO ARE STARING TO LEARN LARAVEL .

Waiting for next videos . :D

sadisherpur
Автор

Great videos, thanks for making them. As a tip, if you are just starting a project, the command:

php artisan make:auth

will take care of a boiler-plating a lot of this. Of course, it is good to see the code created from scratch with play by play explanations. Thanks for working on these!

FlightPhysical
Автор

Thanks Alex for your time you are absolutely amazing <3

I am learning with Laravel 5.4 and in this, we can define the routes by just calling
Auth::routes in our routes->web.php

Or if someone interested to find out the routes itself then go to

Illuminate/Routing/Router.php

and copy that routes in your web.php file
// Registration Routes...
// Password Reset Routes...
Route::post('password/email',


Hope it helps...!

bilalkhalid
Автор

Epic and awesome videoclasses :D! Congrats and thanks for sharing with us all! Eagerly waiting for part 28 haha!

Автор

For 5.4 run 'php artisan make:auth'. In 'resources' you will find new folder 'layouts' and the 'app' file. Remove everything from that file and chop off everything from the 'main' and paste it in the new 'app' file. In every other view where we extends 'main' just remove 'main' file with 'layouts.app' and everything will work as usual. Ranning php artisan serve you will get routes, folders and files for authentication by default! Folow new routes and you will get completely finished authentication! When it come to authentication in Laravel 5.4 you don't even need to touch routes by your own. Run 'php artisan route:list' and see where routes are. The only think you can touch is styling, but that's optional. Just in case, save native project as it is before running 'php artisan make:auth'!

stefan
Автор

Jacurtis, thank you a lot for the series, I'm learning a lot :)

Want to help you with just a bootstrap thing, if you put your labels and inputs, checkboxes and buttons inside some div's with the class "form-group", you won't need to create and add any custom class, it adds top and bot margins and it looks perfectly.

MyShocK
Автор

watching in 2019 with laravel 5.8 😎 thank you php artisan make:auth

egyleader
Автор

Hi Alex, Great tutorials. For Laravel 5.4 just use
Auth::routes();
and it will be generate all route for login, register and logout.

nenadfemic
Автор

Hey Alex, this tutorial for authentication is made when Laravel 5.2 was used. Laravel 5.3 overhauled the way the Auth works, pulling apart the AuthController and making several controllers related to one thing only such as LoginController. Thing is, that the way I am coding as you are doing right now, it will not recognise a getLogin() function. Do you have a tutorial out there for 5.3 authorization (basic like this 1 for 5.2)? If so, it would be highly appreciated. Ofcourse a site I can find more about it will help too; Laravel docs themselves only cast a little light on this.

justinm
Автор

Hello! Thank you for great tutorials. But a lot of people are interested how make multilanguage site on laravel. Can you make tutorial about this topic?

pavliukman
Автор

A seperate video could be useful, since these Routes are not relevant anymore in Laravel 5.4

ImreBertalan
Автор

Hey Alex, this tutorial for authentication is made when Laravel 5.2 was used. Laravel 5.4 overhauled the way the Auth works, pulling apart the AuthController and making several controllers related to one thing only such as LoginController. Thing is, that the way I am coding as you are doing right now, it will not recognise a getLogin() function. Do you have a tutorial out there for 5.4 authorization (basic like this 1 for 5.2)? If so, it would be highly appreciated. Ofcourse a site I can find more about it will help too; Laravel docs themselves only cast a little light on this.

some advice from the comments sugested that we should replace
with
yet its not working, please help, Thanks

tonyjoe
Автор

Hi

Thanks for your great and clear videos.

I have a question regarding to auth.basic. I am using Laravel 5.5. To apply the basic authentication to a specific route I'm attaching it with this middleware syntax:
Route::get('myRoute', function(){
return "something";
})->middleware('auth.basic');
but in all the browser all that I get is an error message: "Symfony \ Component \ HttpKernel \ Exception \ UnauthorizedHttpException No message"
What could be the reason of this error? I didn't find anything at the laracast forums.

andreangc
Автор

In laravel 5.7 I recommend you to read the authentication documentation in laravel docs website. In 5.7 lots of changes. But if you are so hasty (php artisan make:auth) in your command terminal it will generate you authentication controller, routes and views.

gervic
Автор

To follow along in laravel 5.3 since you don't use AuthController anymore I didn't do all that with routes that you did I just simply put in Auth::routes(); which created everything that you did but with the proper controllers and methods. Hopefully that doesn't throw me a road block later on.

Coop
Автор

for everyone with Laravel 5.4 or higher

use this instead of the routes from the video:
Auth::routes()

and do in commandline "php artisan make:auth
This will make the login and register files.


veoronox
Автор

Hi DevMarketer! Would it be possible for you to make a video on parts 27, 28, 29, 30, 30 1/2 on Laravel 5.8 because it's very different with the version of your laravel ? Thanks

ianlcz
Автор

wow man, i enjoy all your videos. keep it up.
please i just want you to help me in displaying all the logged in user with an indicator which shows they are logged in, whereby i can send text and live chart. please you can do it in another video. i will be grateful for that

bimerinoel
Автор

and when i pass route in {!! !!}.. it returns routes not defined error.

mohdhasanchishti
join shbcf.ru