命令行工具
ThinkPHP 提供了强大的命令行工具。
常用命令
创建控制器
bash
php think make:controller Index创建模型
bash
php think make:model User创建中间件
bash
php think make:middleware Auth创建验证器
bash
php think make:validate User自定义命令
创建命令
bash
php think make:command Hello定义命令
php
<?php
namespace app\command;
use think\console\Command;
use think\console\Input;
use think\console\Output;
class Hello extends Command
{
protected function configure()
{
$this->setName('hello')
->setDescription('Say hello');
}
protected function execute(Input $input, Output $output)
{
$output->writeln('Hello ThinkPHP!');
}
}
?>执行命令
bash
php think hello下一步
学习事件系统 → 事件系统
