Running a Zend Framework action from command line

后端 未结 10 1344
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-29 17:01

I would like to run a Zend Framework action to generate some files, from command line. Is this possible and how much change would I need to make to my existing Web project t

10条回答
  •  余生分开走
    2020-11-29 17:23

    akond idea works great, except the error exception isnt rendered by the error controller.

    public function cliAction() {
      $this->_helper->layout->disableLayout();
      $this->_helper->viewRenderer->setNoRender(true);
    
      foreach ($this->_getParam('error_handler') as $error) {
        if ($error instanceof Exception) {
          print "cli-error: " . $error->getMessage() . "\n";
        }
      }
    }
    

    and In Application_Router_Cli, comment off the echo and die statement

    public function assemble($userParams, $name = null, $reset = false, $encode = true) {
    //echo "Not implemented\n";
    }
    

提交回复
热议问题