max / var-dumper
Installs: 2 005
Dependents: 0
Suggesters: 0
Security: 0
Stars: 5
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: >=7.4
- symfony/var-dumper: ^7.0
This package is auto-updated.
Last update: 2024-05-24 10:29:17 UTC
README
var-dumper 适配包,用来将变量打印到浏览器
安装
composer require next/var-dumper
使用
hyperf
修改app/config/autoload/exceptions.php
<?php declare(strict_types=1); return [ 'handler' => [ 'http' => [ Next\VarDumper\Adapter\HyperfDumperHandler::class, Hyperf\HttpServer\Exception\Handler\HttpExceptionHandler::class, App\Exception\Handler\AppExceptionHandler::class, ], ], ];
webman
建立新的异常处理类
<?php namespace App; use Next\VarDumper\Dumper; use Next\VarDumper\DumperHandler; use support\exception\Handler; use Throwable; use Webman\Http\Request; use Webman\Http\Response; class ExceptionHandler extends Handler { use DumperHandler; public function render(Request $request, Throwable $exception): Response { if ($exception instanceof Dumper) { return \response(self::convertToHtml($exception)); } return parent::render($request, $exception); } }
修改config/exception.php
return [ '' => \App\ExceptionHandler::class, ];
其他框架可参考webman配置,引入DumperHandler,将异常转为响应即可
打印
d($request);