Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
吴磊(PHP)
/
admin-skeleton
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 0e0ac094
authored
Jun 08, 2023
by
wulei@ldy.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix readme style
1 parent
0d1f622c
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
4 deletions
README.md
README.md
View file @
0e0ac09
...
...
@@ -113,7 +113,7 @@ $router->group([
#### Api标准化输出
增加了针对
`Api`
接口的标准化输出,默认对整个
`api`
启用。将所有的可
`json`
序列化的数据统一转化为标准化输出。
编写
`api`
代码时无需关注返回结构,只需要返回对应的数据(即
`data`
节点)即可
:
编写
`api`
代码时无需关注返回结构,只需要返回对应的数据(即
`data`
节点)即可
。
```
php
$router->any('test', function() {
return 'test api'; // 字符串
...
...
@@ -176,7 +176,7 @@ public function register()
```
业务异常则创建了
`app\Exceptions\BizException.php`
进行管理,不同场景的异常推荐在
`app\Exceptions`
目录中按照业务创建文件夹进行归类管理。
业务异常继承
`BizException`
,需要覆写异常返回的
`code`
和
`message`
属性,比如归类到
`Auth`
的用户名或密码错误异常
`AccountOrPassWordInvalidException`
:
业务异常继承
`BizException`
,需要覆写异常返回的
`code`
和
`message`
属性,比如归类到
`Auth`
的用户名或密码错误异常
`AccountOrPassWordInvalidException`
```
php
<?php
...
...
@@ -201,7 +201,7 @@ class AccountOrPassWordInvalidException extends BizException
"data"
:
null
}
```
业务异常可以自定义输出内容,需要重写
`BizExcetion`
中的
`render()`
:
业务异常可以自定义输出内容,需要重写
`BizExcetion`
中的
`render()`
```
php
public function render(Request $request)
{
...
...
@@ -210,7 +210,7 @@ public function render(Request $request)
]);
}
```
业务异常默认不上报,但可以按需自定义上报内容(如日志上报或告警),需要重写
`BizExcetion`
中的
`report()`
:
业务异常默认不上报,但可以按需自定义上报内容(如日志上报或告警),需要重写
`BizExcetion`
中的
`report()`
```
php
public function report()
{
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment