tp5或thinkphp5執行shell命令定時執行命令行運行php腳本

application\common.php文件內容如下:

return [
    'app\shell\command\Test',
];

 

application\shell\command\Test.php內容如下:

namespace app\shell\command;

use think\console\Command;
use think\console\Input;
use think\console\Output;
use think\Db;

class Test extends Command
{
    protected function configure()
    {
        parent::configure();
        $this->setName('Test')->setDescription('Test');
    }

    protected function execute(Input $input, Output $output)
    {
        echo 'TestTestTestTest';exit;
    }
}

 

切換到TP5根目錄,即../application/上級目錄(同級有個文件think)。

按住Shift鍵並且右擊鼠標,選擇‘在此處執行shell’。(或者直接cmd切換到該目錄),執行如下命令:

F:\x\www\PHPTutorial\php\php-5.6.27-nts\php.exe .\think Test

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章