当前位置: 首页 > news >正文

thinkphp中命令行工具think使用,可用于快速生成控制器,模型,中间件等

在使用tp框架的时候tp内置了一个think的命令行工具, 这个工具可以帮助我们快速的生成控制器,模型,中间件的代码。 这个工具就和laravel中的 artisan 的作用都差不多,只是名称不同而已。

tp中常用的命令行工具:

1. 快速生成应用

如果使用了多应用模式,可以快速生成一个应用,例如生成demo应用的指令如下:

php think build demo

会自动生成demo应用,自动生成的应用目录包含了controller、model和view目录以及common.php、middleware.php、event.php和provider.php等文件。生成成功后,我们可以直接访问demo应用.

2. 快速生成控制器

 php think make:controller index@Blog
 空控制器生成: php think make:controller index@Blog --plain


  带后缀的类库: php think make:controller index@BlogController


 3. 快速生成模型
 php think make:model index@Blog
 带后缀的类库:php think make:model index@BlogModel

快速生成服务: php think make:service index@BlogService


 4. 快速生成中间件
 php think make:middleware Auth
 
 5. 创建验证器类
 php think make:validate index@User
 
 6. 创建自定义指令
 php think make:command Hello hello

7. 清理缓存
 php think clear
 生成路由映射缓存optimize:route
 php think optimize:route index

php think命令行帮助

php think              

version 8.0.3

Usage:

  command [options] [arguments]

Options:

  -h, --help            Display this help message

  -V, --version         Display this console version

  -q, --quiet           Do not output any message

      --ansi            Force ANSI output

      --no-ansi         Disable ANSI output

  -n, --no-interaction  Do not ask any interactive question

  -v|vv|vvv, --verbose  Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Available commands:

  build             Build App Dirs

  clear             Clear runtime file

  help              Displays help for a command

  list              Lists commands

  run               PHP Built-in Server for ThinkPHP

  version           show thinkphp framework version

 make

  make:command      Create a new command class

  make:controller   Create a new resource controller class

  make:event        Create a new event class

  make:listener     Create a new listener class

  make:middleware   Create a new middleware class

  make:model        Create a new model class

  make:service      Create a new Service class

  make:subscribe    Create a new subscribe class

  make:validate     Create a validate class

 optimize

  optimize:route    Build app route cache.

  optimize:schema   Build database schema cache.

 route

  route:list        show route list.

 service

  service:discover  Discover Services for ThinkPHP

 vendor

  vendor:publish    Publish any publishable assets from vendor packages

http://www.lryc.cn/news/473643.html

相关文章:

  • Discourse 是否支持手机注册
  • 软件测试学习笔记丨Flask框架-请求与响应
  • 【C++笔记】list结构剖析及其模拟实现
  • C#进阶1
  • PHP如何对输出进行转义
  • Windows 10 安装Docker踩过的坑和解决-31/10/2024
  • 【应急响应】Linux植入恶意程序排查流程
  • 微信小程序app.js里面onLaunch里面的函数比page里面的onshow里面的方法后执行
  • 斐波那契时间序列,精准捕捉市场拐点 MT4免费公式源码!
  • 计算机的错误计算(一百四十)
  • JavaEE初阶---网络原理(四)--IP协议/DNS协议
  • LeetCode20:有效的括号
  • 简单介绍Class文件、Dex文件以及ELF文件
  • Vivo开奖了,劝退价。。
  • 鸿蒙打包hvigorw clean报错No npmrc file is matched in the current user folder解决
  • 无人机救援系统基本组成
  • git入门教程
  • AMBA:AHB_Slave_Mux的解析与HREADY、HREADYOUT
  • 初始Linux (2) : 权限
  • 在Mac下安装时间序列软件Hector
  • JVM1.8内存模型
  • windows C#-类型系统(上)
  • 【酷狗音乐】逆向登录参数分析
  • Jenkins面试整理-Jenkins Pipeline 是什么?
  • RHCE第三次实验
  • 基于LORA的一主多从监测系统_4G模块上巴法云
  • pip使用
  • Django ORM详解:外键使用(外键逻辑关联)与查询优化
  • 【Python】实战:使用input()从键盘获取一个字符串,判断这个字符串在列表中是否存在(函数体不能使用in),返回结果为True或False
  • 【YApi】接口管理平台