龙岩易富通网络科技有限公司

龙岩小程序开发,龙岩分销系统

centos 定时执行 think命令

2025.06.21 | 39阅读 | 0条评论 | php

在TP5中自定义hello命令

<?php

    protected function configure()

    {

        $this->setName('hello')                      //定义命令的名字

        ->setDescription('This is my command')     //定义命令的描述

        ->addArgument('name')                      //增加一个名字参数

        ->addArgument('age');                      //增加一个年龄参数

    }


    protected function execute(Input $input, Output $output)

    {

        //获取输入的参数

        $name = $input->getArgument('name');

        $age = $input->getArgument('age');


        //输出获得的参数

        $output->writeln("My name is $name ,age is $age");

    }


centos定时执行

* * * * *  php /path/to/your/project/think hello

赞 (

发表评论