Php artisan make:auth 命令未定义
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/34545641/
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
Php artisan make:auth command is not defined
提问by naan
I am trying to run this command in laravel 5.2 but it's not working.
我正在尝试在 laravel 5.2 中运行此命令,但它不起作用。
php artisan make:auth
and prompts with these statements.
并用这些语句提示。
[InvalidArgumentException]
Command "make:auth" is not defined
Did you mean one of these?
make:test
make:request
make:migration
make:seeder
make:middleware
make:controller
make:provider
make:policy
make:event
make:console
make:job
make:listener
make:model
make:command
回答by Luis Fernando Montoya
For Laravel >=6
对于 Laravel >=6
composer require laravel/ui
php artisan ui vue --auth
php artisan migrate
Reference : Laravel Documentation for authentication
参考:Laravel 认证文档
it looks you are not using Laravel 5.2, these are the available make commands in L5.2 and you are missing more than just the make:auth command
看起来你没有使用 Laravel 5.2,这些是 L5.2 中可用的 make 命令,你缺少的不仅仅是 make:auth 命令
make:auth Scaffold basic login and registration views and routes
make:console Create a new Artisan command
make:controller Create a new controller class
make:entity Create a new entity.
make:event Create a new event class
make:job Create a new job class
make:listener Create a new event listener class
make:middleware Create a new middleware class
make:migration Create a new migration file
make:model Create a new Eloquent model class
make:policy Create a new policy class
make:presenter Create a new presenter.
make:provider Create a new service provider class
make:repository Create a new repository.
make:request Create a new form request class
make:seeder Create a new seeder class
make:test Create a new test class
make:transformer Create a new transformer.
Be sure you have this dependency in your composer.json file
确保你的 composer.json 文件中有这个依赖项
"laravel/framework": "5.2.*",
Then run
然后运行
composer update
回答by Nino
Update for Laravel 6
Laravel 6 更新
Now that Laravel 6 is releasedyou need to install laravel/ui
.
现在 Laravel 6已经发布,你需要安装laravel/ui
.
composer require laravel/ui --dev
php artisan ui vue --auth
You can change vue
with react
if you use React in your project (see Using React).
如果您在项目中使用 React vue
,react
则可以更改with (请参阅使用 React)。
And then you need to perform the migrations and compile the frontend
然后你需要执行迁移并编译前端
php artisan migrate
npm install && npm run dev
Source : Laravel Documentation for authentication
Want to get started fast? Install the laravel/ui Composer package and run php artisan ui vue --auth in a fresh Laravel application. After migrating your database, navigate your browser to http://your-app.test/registeror any other URL that is assigned to your application. These commands will take care of scaffolding your entire authentication system!
想快速入门?安装 laravel/ui Composer 包并在新的 Laravel 应用程序中运行 php artisan ui vue --auth。迁移数据库后,将浏览器导航到 http://your-app.test/register或分配给应用程序的任何其他 URL。这些命令将负责搭建整个身份验证系统!
Note: That's only if you want to use scaffolding, you can use the default User model and the Eloquent authentication driver.
注意:只有当你想使用脚手架时,你才可以使用默认的 User 模型和 Eloquent 身份验证驱动程序。
回答by panjeh
In Laravel 6.0 make:auth no longer exists. Read more here
在 Laravel 6.0 make:auth 不再存在。在这里阅读更多
A- Shorthand:
A-速记:
Update Nov 18th:Taylor just released Laravel Installer 2.3.0 added a new "--auth" flag to create a new project with the authentication scaffolding installed!
11 月 18 日更新:Taylor 刚刚发布了 Laravel Installer 2.3.0,添加了一个新的“--auth”标志来创建一个安装了身份验证脚手架的新项目!
To update laravel installerread here
要更新 Laravel 安装程序,请阅读此处
It means we can do:
这意味着我们可以:
laravel new project --auth
cd project
php artisan migrate
npm install
npm run dev
Which is a shorthand of commands in the Section B. Also read more here
这是 B 部分中命令的简写。也可以在此处阅读更多内容
B - Details:
B - 详细信息:
Follow these three steps
按照这三个步骤
Step 1 -First do this:
第 1 步 -首先执行此操作:
laravel new project
cd project
composer require laravel/ui --dev
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 脚手架包。
Step 2 -Then do this:
第 2 步 -然后执行以下操作:
php artisan ui bootstrap --auth
php artisan migrate
or
或者
php artisan ui vue --auth
php artisan migrate
instead of
代替
php artisan make:auth ( which works for Laravel 5.8 and older versions )
More Optionshere
更多选项在这里
php artisan ui:auth
The above command will generate only 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.
如果您之前已经运行过该命令,则控制台命令将提示您确认覆盖身份验证文件。
// 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
To see differencesread this article
要查看差异,请阅读本文
Step 3 -Then you need to do:
第 3 步 -然后您需要执行以下操作:
npm install
npm run dev
回答by Dilip Hirapara
In the Laravel 6 application the make:auth
command no longer exists.
在 Laravel 6 应用程序中,该make:auth
命令不再存在。
Laravel UI is a new first-party package that extracts the UI portion of a Laravel project into a separate laravel/uipackage. The separate package enables the Laravel team to iterate on the UI package separately from the main Laravel codebase.
Laravel UI 是一个新的第一方包,它将 Laravel 项目的 UI 部分提取到一个单独的laravel/ui包中。单独的包使 Laravel 团队能够独立于主 Laravel 代码库迭代 UI 包。
You can install the laravel/ui
package via composer:
您可以laravel/ui
通过 composer安装软件包:
composer require laravel/ui
The ui:auth
Command
该ui:auth
命令
Besides the new ui command, the laravel/ui
package comes with another command for generating the auth scaffolding:
除了新的 ui 命令之外,该laravel/ui
软件包还附带了另一个用于生成 auth 脚手架的命令:
php artisan ui:auth
If you run the ui:auth
command, it will generate the auth routes, a HomeController, auth views, and a app.blade.phplayout file.
如果您运行该ui:auth
命令,它将生成 auth 路由、一个HomeController、auth views和一个app.blade.php布局文件。
If you want to generate the views alone, type the following command instead:
如果要单独生成视图,请键入以下命令:
php artisan ui:auth --views
If you want to generate the auth scaffolding at the same time:
如果要同时生成 auth 脚手架:
php artisan ui vue --auth
php artisan ui react --auth
php artisan ui vue --auth
command will create all of the views you need for authentication and place them in the resources/views/auth
directory
php artisan ui vue --auth
命令将创建身份验证所需的所有视图并将它们放在resources/views/auth
目录中
The ui
command will also create a resources/views/layouts
directory containing a base layout for your application. All of these views use the Bootstrap CSS framework, but you are free to customize them however you wish.
该ui
命令还将resources/views/layouts
为您的应用程序创建一个包含基本布局的目录。所有这些视图都使用 Bootstrap CSS 框架,但您可以随意自定义它们。
More detail follow. laravel-news& documentation
更多细节如下。laravel-新闻和文档
Simply you've to follow this two-step.
只需遵循这两个步骤即可。
composer require laravel/ui
php artisan ui:auth
回答by zaffar
In short and precise, all you need to do is
简而言之,您需要做的就是
composer require laravel/ui --dev
php artisan ui vue --auth
and then the migratephp artisan migrate
.
php artisan ui vue --auth
然后迁移php artisan migrate
。
Just for an overview of Laravel Authentication
仅用于 Laravel 身份验证的概述
Laravel Authentication facilities comes with Guardand Providers, Guardsdefine how users are authenticated for each request whereas Providersdefine how users are retrieved from you persistent storage.
Laravel 身份验证工具带有Guard和Providers,Guards定义了如何为每个请求对用户进行身份验证,而Providers定义如何从持久存储中检索用户。
Database Consideration -By default Laravel includes an App\User Eloquent Model in your app directory.
数据库注意事项 -默认情况下,Laravel 在您的应用程序目录中包含一个 App\User Eloquent 模型。
Auth Namespace -App\Http\Controllers\Auth
身份验证命名空间 -App\Http\Controllers\Auth
Controllers -RegisterController, LoginController, ForgotPasswordController and ResetPasswordController, all names are meaningful and easy to understand!
控制器——RegisterController、LoginController、ForgotPasswordController 和ResetPasswordController,所有的名字都有意义且易于理解!
Routing -Laravel/ui package provides a quick way to scaffold all the routes and views you need for authentication using a few simple commands (as mentioned in the start instead of make:auth).
路由 -Laravel/ui 包提供了一种快速的方法来使用一些简单的命令(如开始而不是make:auth 中提到的)来构建身份验证所需的所有路由和视图。
You can disable any newly created controller, e. g. RegisterController and modify your route declaration like, Auth::routes(['register' => false]); For further detail please look into the Laravel Documentation.
您可以禁用任何新创建的控制器,例如 RegisterController 并修改您的路由声明,如 Auth::routes(['register' => false]); 有关更多详细信息,请查看Laravel 文档。