yii执行php脚本的方法

这篇文章给大家分享的是有关yii执行php脚本的方法的内容。小编觉得挺实用的,因此分享给大家做个参考。一起跟随小编过来看看吧。

1、编码执行

示例:

<?php

/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/4/12 0012
 * Time: 下午 5:43
 */

/**
 * 示例代码
 * Class TestCommand
 */
class TestCommand extends CConsoleCommand
{
    /**
     *
     * 测试(项目根目录下执行)
     *
     * 脚本执行示例:
     *      windows环境:
     *                  >yiic.bat Test Index
     *      linux环境:
     *                  >yiic Test Index
     */
    public function actionIndex()
    {
        echo "ok";
        exit();
    }
}

(相关教程推荐:yii框架)

2、cmd执行

yiic.bat Test Index


yiic Test Index

3、windows定时执行

生成脚本.bat文件

D:\phpStudy\WWW\wwwerp\protected\yiic.bat ebaycrontab run

添加定时任务:

taskschd.msc启动定时任务设置窗口

感谢各位的阅读!关于yii执行php脚本的方法就分享到这里了,希望以上内容可以对大家有一定的帮助,让大家可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到吧!