Laravel 入门:05-Artisan 命令行

Laravel 的 artisan 命令能够便捷的创建各种脚手架,事半功倍。php artisan list, php artisan make:

hefengbao 发布于 2022.12.13 ,最后更新于 2023.09.18

artisan 命令提供了许多有用的工具,可以使用 list 命令查看:

php artisan list

比较常用的是生成脚手架(scaffold),可以通过运行命令 php artisan make 查看, 例如:

# 创建控制器
php artisan make:controller UserController

# 创建模型
php artisan make:model Post

# 创建请求验证文件
php artisan make:request UserRequest

上面的举例是最基础的,比如 php artisan make:model Post 后面还可以添加参数:

# 同时生成数据库迁移文件
php artisan make:model Post -m

# 同时生成控制器
php artisan make:model Post -c

可以使用 help 命令查看详细的参数说明, 例如:

php artian help make:model

先了解一下,在接下来的文章中会用到大部分 make 相关的命令。

参考文档 https://learnku.com/docs/laravel/9.x/artisan/12222

Demo:https://github.com/hefengbao/laravel-demo

Laravel    Laravel   Laravel 入门  

hefengbao

暂无个人简介

有0条评论

发表评论

您的电子邮箱地址不会被公开。 必填项已用 * 标注

来源:

https://www.8ug.icu/articles/laravel-tutorial-05-artisan-command-gqDbqL0RNV