PHP code example of finntenzor / think-report
1. Go to this page and download the library: Download finntenzor/think-report library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
finntenzor / think-report example snippets php
// 异常处理handle类 留空使用 \think\exception\Handle
'exception_handle' => '\\finntenzor\\report\\ExceptionHandle',
php
\finntenzor\report\Report::route('reports');
php
Route::group('reports', function () {
Route::get('/:id', 'finntenzor/reports/getReportById');
Route::get('/', 'finntenzor/reports/getReportList');
});
php
use finntenzor\report\Report;
Route::group('app', function () {
Route::group('api', function () {
// 一些其他路由
});
// 将app/reports注册为错误报告路由
Report::route('reports');
});
php
use finntenzor\report\Report;
Route::group('app', function () {
Route::group('api', function () {
// 一些其他路由
});
// 将app/reports注册为错误报告路由
Report::route('reports')->middleware('MustAdmin');
});
php
namespace app\index\common;
use finntenzor\report\ResponseBuilder;
class ExceptionResponseBuilder implements ResponseBuilder
{
/**
* @param \Exception $e 异常
* @return mixed 响应
*/
public function debugResponse($e)
{
return $e->getMessage();
}
/**
* @return mixed 响应
*/
public function deployResponse()
{
return '哦吼,页面错误了,请联系管理员哦~';
}
}
php
// ....
// 应用容器绑定定义
return [
// 将工具的ResponseBuilder接口绑定到自定义的Builder类上
\finntenzor\report\ResponseBuilder::class => \app\index\common\ExceptionResponseBuilder::class
];
// 或者你也可以使用命令式的绑定:
bind(\finntenzor\report\ResponseBuilder::class, \app\index\common\ExceptionResponseBuilder::class)