Create cronjob with Zend Framework

前端 未结 13 2119
广开言路
广开言路 2020-12-13 14:32

I am trying to write a cronjob controller, so I can call one website and have all modules cronjob.php executed. Now my problem is how do I do that?

Would curl be an

13条回答
  •  离开以前
    2020-12-13 14:57

    For Zend Framework I am currently using the code outlined bellow. The script only includes the portal file index.php, where all the paths, environment and other Zendy code is bootstrapped. By defining a constant in the cron script we cancel the final step , where the application is run.

    This means the application is only setup, not even bootstrapped. At this point we start bootstraping the resources we need and that is that

    //public/index.php
    
    if(!defined('DONT_RUN_APP') || DONT_RUN_APP == false) {  
        $application->bootstrap()->run();
    }
    
    // application/../cron/cronjob.php
    
    define("DONT_RUN_APP",true);
    require(realpath('/srv/www/project/public/index.php'));
    $application->bootstrap('config');
    $application->bootstrap('db');
    
    //cron code follows
    

提交回复
热议问题