Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove Auth in Laravel (PHP artisan)

With this command php artisan make:authI got all the auth stuffs, but I would like to know how to remove it, or just how to reinitialize.

I've deleted all files, that was created, but when I re-run the command, this doesn't create the mysql user table again

like image 428
Vixed Avatar asked Jan 25 '17 15:01

Vixed


People also ask

How do I remove Auth route in Laravel?

You can easily remove laravel standard authentication routes by setting false in your auth reference. E.g. Auth::routes(['register' => false]); . This also works for login , verify etc.

What is Auth in Laravel 8?

It lets you scaffold authentication views, controllers, and routes using Laravel Breeze.

Where is Auth routes in Laravel?

Auth::routes() is just a helper class that helps you generate all the routes required for user authentication. You can browse the code here https://github.com/laravel/framework/blob/5.8/src/Illuminate/Routing/Router.php instead.


4 Answers

Look at the make:auth command source code to understand what exactly files this command added or changed and revert the changes back.

As you can see, you should remove some views and couple of the controllers.

auth/login.blade.php
auth/register.blade.php
auth/passwords/email.blade.php
auth/passwords/reset.blade.php
layouts/app.blade.php
home.blade.php
like image 74
Alexey Mezenin Avatar answered Oct 03 '22 00:10

Alexey Mezenin


Check the make:auth command's source to understand the files created by it or the changes.

You will need to delete these files

  1. auth/login.blade.php
  2. auth/register.blade.php
  3. auth/passwords/email.blade.php
  4. auth/passwords/reset.blade.php
  5. layouts/app.blade.php
  6. home.blade.php

Once that is done

Go to routes/web.php, delete the routes created by the command make:auth. Remove these two lines and your project will run properly.

Auth::routes();

Route::get('/home', 'HomeController@index');
like image 32
Mayur Budukale Avatar answered Oct 03 '22 00:10

Mayur Budukale


You need to remove user table from database. Also remove migrations entry from migrate tables. and than comment route code of auth from web.php file in route folder. like

Auth::routes();

also comment middleware from HomeController __construct() function.

$this->middleware('auth'); 
like image 22
Amit Mandaviya Avatar answered Oct 03 '22 01:10

Amit Mandaviya


remove

resources/views/auth   
resources/views/home.blade.php 
resources/views/layouts

(optional, if you don't want it. It won't affect your code)

then delete

Auth::routes(); 
Route::get('/home','HomeController@index')->name('home');

then edit the function in HomeController.php to

public function index()
{
   return view('welcome');
}

for perfection sake
run php artisan migrate:refresh

like image 24
Michael Enitan Avatar answered Oct 03 '22 01:10

Michael Enitan