laravel-admin 控制台命令创建管理员账户

Laravel-admin有几个内置的控制台命令来帮助开发。一旦安装了 laravel-admin,你就可以直接使用它们。

Php Artisan Admin

使用该php artisan admin命令显示当前版本Laravel-admin并列出所有可用的管理命令。

$ php artisan admin
    __                                __                __
      _
   / /   ____ __________ __   _____  / /     ____ _____/ /___
___  (_)___
  / /   / __ `/ ___/ __ `/ | / / _ \/ /_____/ __ `/ __  / __ `
__ \/ / __ \
 / /___/ /_/ / /  / /_/ /| |/ /  __/ /_____/ /_/ / /_/ / / / /
 / / / / / /
/_____/\__,_/_/   \__,_/ |___/\___/_/      \__,_/\__,_/_/ /_/
/_/_/_/ /_/


Laravel-admin version 1.8.14

Available commands:
 admin:make             Make admin controller
 admin:controller       Make admin controller from giving mode
l
 admin:menu             Show the admin menu
 admin:install          Install the admin package
 admin:publish          re-publish laravel-admin's assets, con
figuration, language and migration files. If you want overwrit
e the existing files, you can add the `--force` option
 admin:uninstall        Uninstall the admin package
 admin:import           Import a Laravel-admin extension
 admin:create-user      Create a admin user
 admin:reset-password   Reset password for a specific admin us
er
 admin:extend           Build a Laravel-admin extension
 admin:export-seed      Export seed a Laravel-admin database t
ables menu, roles and permissions
 admin:minify           Minify the CSS and JS
 admin:form             Make admin form widget
 admin:permissions      generate admin permission base on tabl
e name
 admin:action           Make a admin action
 admin:generate-menu    Generate menu items based on registere
d routes.
 admin:config           Compare the difference between the adm
in config file and the original

Php Artisan Admin:Make

php artisan admin:make

Php Artisan Admin:Make

artisan admin:install & artisan admin:uninstall

这两个命令用于安装和卸载 laravel-admin 包,其中admin:install将在项目中创建多个文件或目录。

.
├── app/Admin/
├── config/admin.php
├── resources/lang/
│     └── lang/
│       ├── en/admin.php
│       └── zh-CN/admin.php
├── database/migrations/2016_01_04_173148_create_admin_tables.php
└── public/vendor/laravel-admin/

运行artisan admin:uninstall会删除这些文件或目录

Php Artisan Admin:Create-User

从 v1.5.19 开始

此命令用于创建管理员用户。交互填写用户名和密码并选择角色后,即可创建用户。

 php artisan admin:create-user

 Please enter a username to login:
 > admin

 Please enter a password to login:
 >

 Please enter a name to display:
 > admin

User [admin] created successfully.

这个时候去查看数据库表里面admin_users表增加了一条记录。

admin_users 表

本文参考: https://laravel-admin.org/docs/zh/1.x/commands