Laravel 6 中未定义工匠命令“make:auth”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/57774231/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 17:56:52  来源:igfitidea点击:

Artisan command "make:auth" is not defined in Laravel 6

laravellaravel-6

提问by af rizal

I have a problem when creating login/auth in Laravel 6. I typed "make: auth" in the terminal and I get an error "Command" make: auth "appears not defined." Is there a solution for this?

我在 Laravel 6 中创建登录/身份验证时遇到问题。我在终端中输入了“make: auth”,但出现错误“Command” make: auth“appears not defined”。有解决方案吗?

回答by ceejayoz

Looks like L6 moves the Auth scaffolding into a separate package.

看起来 L6 将 Auth 脚手架移动到一个单独的包中

https://laravel.com/docs/6.0/authentication

https://laravel.com/docs/6.0/authentication

Want to get started fast? Install the laravel/uiComposer package and run php artisan ui vue --authin a fresh Laravel application.

想快速入门?安装laravel/uiComposer 包并php artisan ui vue --auth在新的 Laravel 应用程序中运行。

回答by Vipertecpro

https://laravel.com/docs/7.x/authentication#included-routing

https://laravel.com/docs/7.x/authentication#included-routing

Laravel's laravel/uipackageprovides a quick way to scaffold all of the routes and views you need for authentication using a few simple commands:

Laravel 的laravel/ui提供了一种快速的方法来使用一些简单的命令来构建身份验证所需的所有路由和视图:

composer require laravel/ui --dev

php artisan ui vue --auth

After above commands, you'll get following output :-

执行上述命令后,您将获得以下输出:-

Vue scaffolding installed successfully.
Please run "npm install && npm run dev" to compile your fresh scaffolding.
Authentication scaffolding generated successfully.

Now after running this command run this command, for Vue scaffolding

现在运行此命令后运行此命令,用于Vue 脚手架

npm install && npm run dev

If you're get following error message

如果您收到以下错误消息

npm ERR! Your cache folder contains root-owned files, due to a bug in
npm ERR! previous versions of npm which has since been addressed.
npm ERR! 
npm ERR! To permanently fix this problem, please run:
npm ERR!   sudo chown -R 1000:1000 "/home/shiv/.npm"
npm ERR! code EACCES
npm ERR! syscall open

Then give permission user to access .npm files from system

然后授予用户从系统访问 .npm 文件的权限

sudo chown -R 1000:1000 "/home/system_user_name/.npm"

As i now understood clearly,running "sudo command is dangerous for npm configurations"

正如我现在清楚地理解的那样,运行“sudo 命令对于 npm 配置是危险的”

Please look it this threat for more clear understanding :- npm throws error without sudo

请查看此威胁以获得更清晰的理解:- npm 在没有 sudo 的情况下引发错误

回答by Udhav Sarvaiya

One major change introduced in Laravel 6.0 is the removal of php artisan make:authCommand

Laravel 6.0 中引入的一项主要变化是删除了php artisan make:authCommand

Basically, make:authcommand was used to create the authentication scaffolding. The concept has not been removed, but the way of implementation has been changed

基本上,make:auth命令用于创建身份验证脚手架。概念没有被去除,但实现方式已经改变

Update for Laravel 6:The New Way

Laravel 6 更新:新方式

Authentication support is now added with the help of a package now (More details)

现在在软件包的帮助下添加了身份验证支持(更多详细信息

The command to implement Auth is as follows:

实现Auth的命令如下:

composer require laravel/ui
php artisan ui vue --auth

This command will install a layout view, registration and login views, as well as routes for all authentication end-points. A HomeController will also be generated to handle post-login requests to your application's dashboard.

此命令将安装布局视图、注册和登录视图,以及所有身份验证端点的路由。还将生成一个 HomeController 来处理对应用程序仪表板的登录后请求。



NOTE:If your Login and Register page only shows plain HTML. And CSS is not loading properly then run this two command:

注意:如果您的登录和注册页面仅显示纯 HTML。并且 CSS 没有正确加载然后运行这两个命令:

npm install
npm run dev

回答by panjeh

In Laravel 6.0 make:auth no longer exists. Read more here

在 Laravel 6.0 make:auth 不再存在。在这里阅读更多

1 - First do this:

1 - 首先这样做:

composer require laravel/ui

Note:Laravel UI Composer package is a new first-party package that extracts the UI portion of a Laravel project ( frontend scaffolding typically provided with previous releases of Laravel ) into a separate laravel/ui package. The separate package enables the Laravel team to update, develop and version UI scaffolding package separately from the primary framework and the main Laravel codebase.

注意:Laravel UI Composer 包是一个新的第一方包,它将 Laravel 项目的 UI 部分(前端脚手架通常与 Laravel 的早期版本一起提供)提取到一个单独的 laravel/ui 包中。单独的包使 Laravel 团队能够独立于主要框架和主要 Laravel 代码库更新、开发和版本 UI 脚手架包。

2 - Then do this:

2 - 然后这样做:

php artisan ui:auth

instead of

代替

php artisan make:auth  ( which works for Laravel 5.8 and older versions )

It will generate the auth routes, a HomeController, auth views, and a app.blade.php layout file.

它将生成 auth 路由、HomeController、auth 视图和 app.blade.php 布局文件。

You can also generate the views only with:

您还可以仅通过以下方式生成视图:

php artisan ui:auth --views

The console command will prompt you to confirm overwriting auth files if you've already run the command before.

如果您之前已经运行过该命令,则控制台命令将提示您确认覆盖身份验证文件。

More Optionshere

更多选项在这里

// Generate basic scaffolding...
php artisan ui vue
php artisan ui react

and also:

并且:

// Generate login / registration scaffolding...
php artisan ui vue --auth
php artisan ui react --auth

回答by lovecoding-laravel

composer require laravel/ui
php artisan ui bootstrap --auth

npm install
npm run dev

回答by munazzil

if you are using laravel 6, then try this command because otherwise this command 'composer require laravel/ui' with this you get only for Laravel 7.0 and up,

如果您使用的是 laravel 6,请尝试此命令,否则此命令 'composer require laravel/ui' 仅适用于 Laravel 7.0 及更高版本,

        composer require laravel/ui "^1.0" --dev

After Install the laravel/ui Composer run below command for auth scaffolding

安装 laravel/ui Composer 后运行以下命令进行身份验证脚手架

        package and run php artisan ui vue --auth 

in a fresh Laravel application or with use documentation.

在新的 Laravel 应用程序或使用文档中。

回答by Carlos

you can copy the composer.json file and the app/Exceptions/Handler.php files from the official laravel 7 repo. link to repo: https://github.com/laravel/laravel

您可以从官方 Laravel 7 存储库中复制 composer.json 文件和 app/Exceptions/Handler.php 文件。回购链接:https: //github.com/laravel/laravel

Then run

然后运行

composer update

composer  require laravel/ui "^2.0"

php artisan ui vue --auth

回答by Paras shah

Laravel verion 6.0

Laravel 6.0 版

  1. composer require laravel/ui
  2. php artisan ui vue --auth
  1. composer require laravel/ui
  2. php artisan ui vue --auth

these commands will help

这些命令会有所帮助