📜  php artisan auth - Shell-Bash (1)

📅  最后修改于: 2023-12-03 15:33:28.030000             🧑  作者: Mango

使用 PHP Artisan Auth 命令行工具

PHP Artisan Auth 是 Laravel 框架中的一个内置命令行工具。它可以生成包含基本认证功能的控制器、视图和路由文件,以便快速构建认证系统。

如何使用

使用 PHP Artisan Auth 命令行工具非常简单,只需要在终端中执行以下命令:

php artisan auth

执行命令后,你可以看到控制台如下输出:

Authentication scaffolding generated successfully.

这表示生成认证系统所需要的文件已经成功创建。

生成的文件

执行 PHP Artisan Auth 命令后,会生成以下文件:

控制器

  • app/Http/Controllers/Auth/LoginController.php
  • app/Http/Controllers/Auth/RegisterController.php
  • app/Http/Controllers/Auth/ForgotPasswordController.php
  • app/Http/Controllers/Auth/ResetPasswordController.php
  • app/Http/Controllers/Auth/VerificationController.php

视图

  • resources/views/auth/login.blade.php
  • resources/views/auth/register.blade.php
  • resources/views/auth/passwords/email.blade.php
  • resources/views/auth/passwords/reset.blade.php

路由

  • routes/web.php
自定义生成选项

如果你需要自定义生成选项,可以执行以下命令:

php artisan auth:controller
php artisan auth:request
php artisan auth:factory
php artisan auth:views
php artisan auth:routes
php artisan auth

每个命令都有对应的参数和选项,可以通过以下命令获取指令帮助:

php artisan help auth:controller
php artisan help auth:request
php artisan help auth:factory
php artisan help auth:views
php artisan help auth:routes
php artisan help auth