首页 » Web前端 » thinkphp模板挪用php函数挪用技巧_ThinkPHP 运用敕令行 cli think 调用

thinkphp模板挪用php函数挪用技巧_ThinkPHP 运用敕令行 cli think 调用

访客 2024-11-06 0

扫一扫用手机浏览

文章目录 [+]

首先,在application\command目录(目录没有则创建)下新建hello.php:

<?phpnamespace app\command;use think\console\Command;use think\console\Input;use think\console\input\Argument;use think\console\input\Option;use think\console\Output;use think\Request;class hello extends Command { / 重写configure {@inheritdoc} / protected function configure(){ $this // 命令的名字("think" 后面的部分) ->setName('hello') // 配置一个参数 利用$input->getArgument('username')获取 // ->addArgument('username') // 运行 "php think list" 时的简短描述 ->setDescription('定时任务微做事.') // 运行命令时利用 "--help" 选项时的完全命令描述 ->setHelp("定时任务微做事 无参数"); } / 重写execute {@inheritdoc} @param Input $input @param Output $output / protected function execute(Input $input, Output $output){ echo 'hello world'; }}

修正application/command.php(没有则创建)

thinkphp模板挪用php函数挪用技巧_ThinkPHP 运用敕令行 cli think 调用

<?phpreturn [ "app\command\hello",];

cd到项目根目录,在命令行输入

thinkphp模板挪用php函数挪用技巧_ThinkPHP 运用敕令行 cli think 调用
(图片来自网络侵删)

php think hello

OK,成功调用

hello world

hello world

标签:

相关文章

房山第一探寻历史文化名区的魅力与发展

房山区,位于北京市西南部,历史悠久,文化底蕴深厚。作为北京市的一个重要组成部分,房山区的发展始终与首都的发展紧密相连。房山区积极推...

Web前端 2025-02-18 阅读0 评论0

手机话费开钻代码数字时代的便捷生活

我们的生活越来越离不开手机。手机话费作为手机使用过程中的重要组成部分,其充值方式也在不断创新。手机话费开钻代码应运而生,为用户提供...

Web前端 2025-02-18 阅读0 评论0

探寻专业奥秘如何查询自己专业的代码

计算机科学已成为当今社会不可或缺的一部分。掌握一门专业代码对于个人发展具有重要意义。面对繁杂的学科体系,如何查询自己专业的代码成为...

Web前端 2025-02-18 阅读0 评论0