tp5自带的命令行工具
进入项目目录最外层
1、创建文件名为abc.php的脚本
php think make:command abc
2、直接在文件内execute方法里写要执行的脚本内容(可以使用tp自带的数据库等工具类)
<?php
namespace app\command;
use think\console\Command;
use think\console\Input;
use think\console\Output;
use think\Db;
class abc extends Command
{
protected function configure()
{
// 指令配置
$this->setName('abc');
// 设置参数
}
protected function execute(Input $input, Output $output)
{
$res = Db::name('user_finance')->find();var_dump($res);exit;
echo 'ddd';exit;
// 指令输出
$output->writeln('abc.php');
}
}
3、执行该脚本命令: php think abc