PHPackages                             doing/extp - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Debugging &amp; Profiling](/categories/debugging)
4. /
5. doing/extp

ActiveLibrary[Debugging &amp; Profiling](/categories/debugging)

doing/extp
==========

基于ThinkPHP5的异常类

029

Since Mar 29Pushed 8y agoCompare

[ Source](https://github.com/Doing0/extp)[ Packagist](https://packagist.org/packages/doing/extp)[ RSS](/packages/doing-extp/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

使用说明
====

[](#使用说明)

介绍
--

[](#介绍)

> 1. 是基于ThinkPHP5(下简写TP5)重写的抛出异常类，故只能用于TP5内部不能适用于其他框架
> 2. 请用composer安装此包
> 3. 安装命令：`composer require doing/extp 版本号`。例`composer require doing/extp 1.*`
> 4. 请先更改TP5的配置选项引入此类（在application/config.php里面搜索`exception_handle`,默认值是空修改成`'exception_handle' => '\extp\core\ExceptionHandler',`

使用步骤
----

[](#使用步骤)

> 前提：必须引用对应的类如:`use extp\diy\NullException;`

使用场景一:快速抛出异常

```
//直接New一个application/lib/exception/下的自定义异常对象快速抛出异常
throw New NullException();
说明:取对象类的默认属性值:msg，error_code,code
返回的信息
{
     msg: "我是提示信息",//提示信息
     error_code: "40000",//自定义错误码
     request_url: "/credits/public/index.php/api/index/index"//请求地址
 }
 说明:http的状态码code是提现在header上

```

使用场景二:自定义返回信息

```
$exceptions['msg'] = '我是提示信息';
$exceptions['error_code'] = '40000'//自定义错误码
exceptions['code'] = '401'//http的状态码
throw New NullException($exceptions);
说明:自定义类有三个属性:需要更改哪一个就传哪一个，如果只修改提示信息msg和自定义错误码,其他信息就使类的默认属性值,那就就只需要传msg和error_code
以上代码可以简写throw New NullException(['msg'=>'我是提示信息','error_code'=>'4000'])
使用时不建议修改code属性,因为是基于http的状态码封装的

```

自定义类的封装

> 1. 建议按Http的状态码分类封装:如NullExcption就代码的是抛出http状态码为404异常:用于查找无数据等情况抛出
> 2. 自定义错误类放在application/lib/exception(在application下创建一个文件夹lib,把下载的doing/extp/exception的`exception`文件夹剪切到以上目录的`lib`下)
> 3. 建议直接复制我已封装的类进行修改(doing/extp/exception里面的文件)
> 4. 3中主要修改地方:文件名和类名保持一直且采用驼峰命名首字母大写全部采用Exception结尾。修改三个对应属性值code,msg,errorCode
> 5. 已封装的4个自定义类说明:NullException(用于404异常及查找无数据等)，ParamsException(用于客户端请求的参数错误异常),SuccessException(用于操作成功如删除成功等操作)，主要说下`ServiceException`类的使用:如果code给600就是抛出第三方的错误:比如调用微信支付时第三方给的错误异常，如果code给500就是我们自己服务器的错误

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/100146bfe4881f02fc2f12b2fb50a4ec2f339233818ca8f5c52c6e8785946514?d=identicon)[Doing](/maintainers/Doing)

---

Top Contributors

[![Doing0](https://avatars.githubusercontent.com/u/36249980?v=4)](https://github.com/Doing0 "Doing0 (17 commits)")

### Embed Badge

![Health badge](/badges/doing-extp/health.svg)

```
[![Health](https://phpackages.com/badges/doing-extp/health.svg)](https://phpackages.com/packages/doing-extp)
```

###  Alternatives

[symfony/stopwatch

Provides a way to profile code

2.8k387.2M918](/packages/symfony-stopwatch)[fruitcake/laravel-debugbar

PHP Debugbar integration for Laravel

19.1k662.9k29](/packages/fruitcake-laravel-debugbar)[spatie/ignition

A beautiful error page for PHP applications.

510147.6M69](/packages/spatie-ignition)[jokkedk/webgrind

Webgrind is a Xdebug profiling web frontend in PHP5. It implements a subset of the features of kcachegrind and installs in seconds and works on all platforms. For quick'n'dirty optimizations it does the job.

3.3k193.0k](/packages/jokkedk-webgrind)[koriym/printo

An object graph visualizer.

1421.8M2](/packages/koriym-printo)[soloterm/dumps

A Laravel command to intercept dumps from your Laravel application.

125285.7k3](/packages/soloterm-dumps)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
