在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
发表评论