如何在 Laravel 中删除 Auth(PHP 工匠)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/41855619/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to remove Auth in Laravel (PHP artisan)
提问by Vixed
With this command php artisan make:auth
I got all the authstuffs, but I would like to know how to remove it, or just how to reinitialize.
使用此命令,php artisan make:auth
我获得了所有auth 的东西,但我想知道如何删除它,或者只是如何重新初始化。
I've deleted all files, that was created, but when I re-run the command, this doesn't create the mysql user table again
我已经删除了所有创建的文件,但是当我重新运行命令时,这不会再次创建 mysql 用户表
采纳答案by Alexey Mezenin
Look at the make:auth
command source codeto understand what exactly files this command added or changed and revert the changes back.
查看make:auth
命令源代码以了解此命令添加或更改的确切文件,并将更改还原。
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
回答by Mayur Budukale
Check the make:auth command's source to understand the files created by it or the changes.
检查 make:auth 命令的源代码以了解它创建的文件或更改。
You will need to delete these files
您将需要删除这些文件
- 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
- 身份验证/登录.blade.php
- 身份验证/register.blade.php
- 身份验证/密码/email.blade.php
- 身份验证/密码/reset.blade.php
- 布局/app.blade.php
- 主页.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.
进入routes/web.php,删除make:auth命令创建的路由。删除这两行,您的项目将正常运行。
Auth::routes();
Route::get('/home', 'HomeController@index');
回答by Amit Mandaviya
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
您需要从数据库中删除用户表。还要从迁移表中删除迁移条目。然后从web.php
路由文件夹中的文件注释身份验证的路由代码。喜欢
Auth::routes();
also comment middleware
from HomeController __construct()
function.
也middleware
从HomeController __construct()
功能评论。
$this->middleware('auth');
回答by Michael Enitan
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
然后将 HomeController.php 中的函数编辑为
public function index()
{
return view('welcome');
}
for perfection sake
run php artisan migrate:refresh
为了完美而
奔跑php artisan migrate:refresh
回答by Paul Caleb
try this
尝试这个
php artisan view:clear
this will clear the compiled view for you automatically
这将自动为您清除编译视图
回答by Kamaro Lambert
Just run this code it will fix your issue php artisan auth:clear-reset
只需运行此代码即可解决您的问题 php artisan auth:clear-reset