环境
Windows10 64位 专业版
laravel 5.8 / 5.7
phpstudy v8.0
开发中常用命令 1.生成控制器
php artisan make:controller Admin/TagController --resource
// -- resource 表示生成控制器中常用方法如: 对应curd操作的方法
2.生成模型
php artisan make:model Post
3.迁移
生成迁移文件: php artisan make:migration create_users_table
备注:
php artisan make:migration create_post_tag_pivot --create=post_tag_pivot // 生成迁移文件名是指定的名字, 这里不带s, 即复数
执行迁移: php artisan migrate
回滚: php artisan migrate:rollback
重置: php artisan migrate:reset
4.生成工厂模型文件[填充数据]
php artisan make:factory PostFactory --model=Models/Post // --model=Models/Post 指定对应的模型类文件
5.生成种子数据填充文件
php artisan make:seeder PostsTableSeeder
3,4,5见下面 备注
php artisan make:model Post -m -c //同时生成迁移文件, 模型 , 控制器 php artisan make:model Models/Tag --migration //生成迁移文件, 模型
6.命令行与应用交互 // 如对数据库进行简单的读写操作
php artisan tinker
下面我们在 Laradock 中项目根目录下使用该命令为博客项目创建后台用户 G:\phpstudy_pro\WWW\blog57.test>php artisan tinker Psy Shell v0.9.12 (PHP 7.3.4 — cli) by Justin Hileman >>> 7.创建表单请求类 TagCreateRequest // 前后端分离,不需要使用这种方式 Laravel 的一个优秀特性就是表单请求类,这些类可以对指定表单字段进行验证。 使用如下 Artisan 命令创建一个新的 TagCreateRequest : php artisan make:request TagCreateRequest 创建的类存放在 app/Http/Requests/TagCreateRequest.php 8.创建软连接[文件]
php artisan storage:link
该命令会在根目录下的 public 目录中,创建一个软链 storage 指向 storage/app/public 目录, 这样,就完成了 Web 访问路径配置。 9. 清除各种缓存
Laravel 清理缓存_穿素白衫的中少年的博客-CSDN博客
后续整理 ... |