牛骨文教育服务平台(让学习变的简单)

命令行

ThinkPHP5.0支持Console应用,通过命令行的方式执行一些URL访问不方便或者安全性较高的操作。

我们可以在命令行下面,切换到应用根目录,然后执行php think,会出现下面的提示信息:

>php think
Think Console version 0.1

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 Application Dirs
  clear              Clear runtime file
  help               Displays help for a command
  list               Lists commands
 make
  make:controller    Create a new resource controller class
  make:model         Create a new model class
 optimize
  optimize:autoload  Optimizes PSR0 and PSR4 packages to be loaded with classmaps too, good for production.
  optimize:config    Build config and common file cache.
  optimize:route     Build route cache.

console命令的执行格式一般为:

>php think 指令 参数

下面介绍下系统自带的几个命令,包括:

指令 描述
build自动生成目录和文件
help帮助
list指令列表
clear清除缓存指令
make:controller创建控制器文件
make:model创建模型文件
optimize:autoload生成类库映射文件
optimize:config生成配置缓存文件
optimize:route生成路由缓存文件
optimize:schema生成数据表字段缓存文件

更多的指令可以自己扩展。