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;
}
octane 还是 beta 阶段
更新下 octane 试试