laraval octane debugbar报错config未成功初始化处理

laravel-debugbar v3.5.5
laravel octane 0.2.0

###报错信息

laraveldebugbar
$db->listen(
                    function (
                        $query,
                        $bindings = null,
                        $time = null,
                        $connectionName = null
                    ) use (
                        $db,
                        $queryCollector
                    ) {
                        if (!$this->shouldCollect('db', true)) {//这行第2个请求 一直报错 config不存在
                            return; // Issue 776 : We've turned off collecting after the listener was attached
                        }

临时解决方案如下

octane.php配置文件
OperationTerminated::class => [
            FlushTemporaryContainerInstances::class,
            FlushOctane::class,
//             DisconnectFromDatabases::class,
//             CollectGarbage::class,
        ],
<?php
namespace App\Service;

use Barryvdh\Debugbar\LaravelDebugbar;
use Illuminate\Container\Container;
use Illuminate\Database\Events\QueryExecuted;

class FlushOctane
{
    public function handle($event)
    {
        //laravel debugbar DB::listen(function() use ($db){}); $db是上一个请求的 导致监听触发2次
        $event->sandbox['events']->forget(QueryExecuted::class);
    }
}

找bug代码

LaravelDebugbar类
public function shouldCollect($name, $default = false)
    {
//        file_put_contents('/home/afan/Workspace/w7console/a.txt', 'should:'.spl_object_id($this->app).':'.PHP_EOL, FILE_APPEND);
//        try {
//            $debug = $this->app['config']->get('debugbar.collectors.' . $name, $default);
//            try {
//                throw new Exception('test');
//            }catch (Exception $e1) {
//                Log::channel('success')->error('ex', ['e' => $e1]);
//            }
//
//            return $debug;
//        }catch (Exception $e) {
//            Log::channel('error')->error('ex', ['e' => $e]);
//            file_put_contents('/home/afan/Workspace/w7console/a.txt', 'shoulderr:'.spl_object_id($this->app).':'.PHP_EOL, FILE_APPEND);
//        }
        $debug = $this->app['config']->get('debugbar.collectors.' . $name, $default);
        return $debug;

    }
《L05 电商实战》
从零开发一个电商项目,功能包括电商后台、商品 & SKU 管理、购物车、订单管理、支付宝支付、微信支付、订单退款流程、优惠券等
《G01 Go 实战入门》
从零开始带你一步步开发一个 Go 博客项目,让你在最短的时间内学会使用 Go 进行编码。项目结构很大程度上参考了 Laravel。
讨论数量: 2
游离不2

octane 还是 beta 阶段

3年前 评论
nff93

更新下 octane 试试

3年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!