首页 > 技术文章 > laravel常用命令

qiyunhai 2020-09-21 09:33 原文

启动内置 Web 服务器,访问127.0.0.1:8000即可访问项目

php artisan serve

重新生成APP KEY

php artisan key:generate

定义中间件

php artisan make:middleware CheckToken

快速创建控制器

php artisan make:controller UserController

定义模型

php artisan make:model Flight
// 如果你想要在生成模型时生成数据库迁移,可以使用 --migration 或 -m 选项
php artisan make:model Flight --migration
php artisan make:model Flight -m

创建事件

php artisan event:generate

创建建立session表迁移

php artisan session:table

清除应用程序缓存

php artisan cache:clear

清除路由缓存

php artisan route:clear

清除配置缓存

php artisan config:clear

清除已编译的的视图文件缓存

php artisan view:clear

清除编译缓存

php artisan clear-compiled

另外还可以自定义方法来清除指定缓存

// 使用Artisan::call来定义
// 例:
    Artisan::call('cache:clear');

查看所有可用的 Artisan 命令

php artisan list

推荐阅读