yii2 application应用绑定事件

「爱情、让人受尽委屈。」 2022-05-24 01:18 213阅读 0赞
  1. <?php
  2. use yii\web\Application;
  3. defined('YII_DEBUG') or define('YII_DEBUG', true);
  4. defined('YII_ENV') or define('YII_ENV', 'dev');
  5. require(__DIR__ . '/../../vendor/autoload.php');
  6. require(__DIR__ . '/../../vendor/yiisoft/yii2/Yii.php');
  7. require(__DIR__ . '/../../common/config/bootstrap.php');
  8. require(__DIR__ . '/../config/bootstrap.php');
  9. $config = yii\helpers\ArrayHelper::merge(
  10. require(__DIR__ . '/../../common/config/main.php'),
  11. require(__DIR__ . '/../../common/config/main-local.php'),
  12. require(__DIR__ . '/../config/main.php'),
  13. require(__DIR__ . '/../config/main-local.php')
  14. );
  15. function xhprofStart($event){
  16. xhprof_enable();
  17. }
  18. //尾部
  19. function xhprofEnd($event){
  20. $xhprof_data = xhprof_disable();
  21. $xhprof_root = '/mnt/www/mxhy/backend/web/';
  22. include_once $xhprof_root."xhprof_lib/utils/xhprof_lib.php";
  23. include_once $xhprof_root."xhprof_lib/utils/xhprof_runs.php";
  24. $xhprof_runs = new XHProfRuns_Default();
  25. // $route = $event->action->controller->route;
  26. // $route = str_replace('/','_',$route);
  27. $route = 'mxhy';
  28. $run_id = $xhprof_runs->save_run($xhprof_data, $route);
  29. echo '统计<br>';
  30. $domain = $_SERVER['SERVER_NAME'];
  31. $url = "http://".$domain."/xhprof_html/index.php?run=$run_id&source=$route";
  32. echo '<a target="_blank">'.$url.'</a>';
  33. }
  34. $application = new Application($config);
  35. $application->on(Application::EVENT_BEFORE_REQUEST,'xhprofStart');
  36. $application->on(Application::EVENT_AFTER_REQUEST,'xhprofEnd');
  37. $application->run();

发表评论

表情:
评论列表 (有 0 条评论,213人围观)

还没有评论,来说两句吧...

相关阅读

    相关 select 事件

    select 它的事件是注册在自己标签上的,不是onclick,而是onchange,子标签对低版本浏览器无效,而且也不是正规标准的写法。            

    相关 WEUI 事件

    1、简易的输入同步框 所需用到的事件为bindinput,详情可以查看开发文档 通过bindinput事件来监听输入框的值是否发生改变且获取到改变后的值,之后在js文件...