douzi1350 2015-10-23 07:34
浏览 45

从CLI运行的Zend 2使用HTTP路由而不是控制台路由

I am currently working on a zend 2 project and created a console module that i will use with cronjobs. So far i created a standalone project and everything runs fine locally on my working station. Now i uploaded it to my webproject and activated the module. Now i try to run the controller ( route "message" ) but it doesn't use the console route ... it puts out the html that is generated if you call the website with a browser.

    php public/index.php message

Any idea what i am missing ? It works locally in a standalone project but not on the server. Could there be any complications with the other modules on the web project ?

The new module config /module/Console/config/module.config.php:

// This lines opens the configuration for the console routing
'console' => array(
    'router' => array(
        'routes' => array(
            'messagecron' => array(
                'type'    => 'simple',
                'options' => array(
                    'route'    => 'message',
                    'defaults' => array(
                        'controller' => 'Console\Controller\Message',
                        'action'     => 'send'
                    )
                )
            ),

        )
    )
)

It seems that it is using the basic http route from .../module/Application/config/module.config.php

'router' => array(
    'routes' => array(
        'home' => array(
            'type' => 'Zend\Mvc\Router\Http\Literal',
            'options' => array(
                'route' => '/',
                'defaults' => array(
                    'controller' => 'Basic\Controller\Index',
                    'action' => 'index',
                ),
            ),
        ),
    ),
),
  • 写回答

1条回答 默认 最新

  • doupai6875 2015-10-23 08:34
    关注

    The problem belongs to the server ( 1&1 managed ) i use ... there are two ways of running php.

    1) php public/index.php message
    2) php-cli public/index.php message
    

    The solution is, to use the "-cli" for commandline execution.

    评论

报告相同问题?

悬赏问题

  • ¥15 ogg dd trandata 报错
  • ¥15 高缺失率数据如何选择填充方式
  • ¥50 potsgresql15备份问题
  • ¥15 Mac系统vs code使用phpstudy如何配置debug来调试php
  • ¥15 目前主流的音乐软件,像网易云音乐,QQ音乐他们的前端和后台部分是用的什么技术实现的?求解!
  • ¥60 pb数据库修改与连接
  • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错