简体   繁体   English

TypeRocket:通过Controller调用函数时,php脚本停止运行

[英]TypeRocket: php script stops running when function is called via Controller

I'm trying to utilize FirePHP in typerocket but I'm having trouble when I try to use its API in a Controller . 我正在尝试在Typerocket中使用FirePHP ,但是当我尝试在Controller使用它的API时遇到了麻烦。

I have the the following routes (in routes.php ): 我有以下路由(在routes.php ):

tr_route()->get()->match('/exp-get/')->do('experiment@Customer');
tr_route()->get()->match('/exp-get2/')->do(function() {

  require_once TR_PATH . '/vendor/firephp/firephp-core/lib/FirePHPCore/fb.php';

    echo 'before';
    fb('Hello World!', FirePHP::INFO);
    echo 'after';

});

the CustomerController contains: CustomerController包含:

public function experiment() {

require_once TR_PATH . '/vendor/firephp/firephp-core/lib/FirePHPCore/fb.php';
echo 'before';
fb('Hello World!', FirePHP::INFO);
echo 'after';

}

Now, when I call https://dummy-domain.org/exp-get2/ everything runs as expected, but however, when I call https://dummy-domain.org/exp-get/ only ' before ' is echo ed (or printed) but not the rest! 现在,当我调用https://dummy-domain.org/exp-get2/时,一切都会按预期运行,但是,当我调用https://dummy-domain.org/exp-get/时,仅“ echo之前 ed(或印刷),但其余部分则不行! Unfortunately no errors are logged even though I've configured php logging. 不幸的是,即使我已经配置了php日志记录,也不会记录任何错误。 What might be the reason for this and why isn't the error logged if there is any error? 这可能是什么原因?如果有任何错误,为什么不记录错误?

Additionally, I'm having the issue that I need to explicitly require_once fb.php although FirePHP should be autoloaded, as outside of the do related functions I can use the FirePHP API without having to do this! 另外,我遇​​到了一个问题,尽管FirePHP应该自动加载,但我需要明确地需要require_once fb.php ,因为与do相关的功能之外,我可以使用FirePHP API,而不必这样做! Isn't the autoload working here? 自动加载功能在这里不起作用吗?

Note: I'm using the lastest TypeRocket version. 注意:我使用的是最新的TypeRocket版本。

By further debugging I noticed that the php engine was complaining about that a FirePHP class was not found which is used inside the fb function. 通过进一步的调试,我注意到php引擎抱怨说找不到fb函数中使用的FirePHP类。 As a result I just had to put this statement on top of the class which contains that experiment method: 结果,我只需要将此语句放在包含该experiment方法的类之上:

use \FirePHP;

those require_once TR_PATH . '/vendor/firephp/firephp-core/lib/FirePHPCore/fb.php'; 那些require_once TR_PATH . '/vendor/firephp/firephp-core/lib/FirePHPCore/fb.php'; require_once TR_PATH . '/vendor/firephp/firephp-core/lib/FirePHPCore/fb.php'; lines are unnecessary since the autoloader handels that stuff already. 不需要行,因为自动装带器已经处理了这些东西。

This answer led me to the right direction. 这个答案使我朝着正确的方向前进。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM