2017 © Pedro Peláez
 

library debug

error handle component.

image

fastd/debug

error handle component.

  • Friday, March 24, 2017
  • by JanHuang
  • Repository
  • 1 Watchers
  • 1 Stars
  • 1,640 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 28 Versions
  • 1 % Grown

The README.md

Debug

Latest Stable Version Total Downloads Latest Unstable Version License, (*1)

支持自定义错误页面,自定义响应格式,响应头,支持 fatal error 捕捉,日志纪录等功能。, (*2)

要求

  • PHP 7+

Composer

{
    "fastd/debug": "2.0.x-dev"
}

使用

use FastD\Debug\Debug;
Debug::enable();
trigger_error('demo');

日志使用 Monolog\Logger, 完全自定义 Monolog\Logger 日志,直接注入到 FastD/Debug 对象中即可, (*3)

$logger = new \Monolog\Logger('test');
$stream = new \Monolog\Handler\StreamHandler(__DIR__ . '/test.log');
$stream->setFormatter(new Monolog\Formatter\LineFormatter("[%datetime%] >> %level_name%: >> %message% >> %context% >> %extra%\n"));
$logger->pushHandler($stream);

$debug = \FastD\Debug\Debug::enable(false, $logger);

throw new \Exception('test');

自定义错误页面内容, (*4)

\FastD\Debug\Debug::enable();

class PageException extends \FastD\Debug\Exceptions\HttpException
{
    /**
     * Returns response content.
     *
     * @return string
     */
    public function getContent()
    {
        return file_get_contents(__DIR__ . '/demo.html');
    }
}

throw new PageException('custom');

自定义错误页面使用自定义异常类一样的做法,可以更加灵活处理。, (*5)

自定义异常

自定义异常只需要继承 FastD\Debug\Exceptions\Http\HttpException 对象,对类中的 getStatusCode, getHeaders, getContent 三个方法重写即可, (*6)

可参考例子:, (*7)

自定义响应格式: json.php 自定义页面: page.php, (*8)

Testing

phpunit

License MIT

The Versions

24/03 2017

v2.0.3

2.0.3.0

error handle component.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar JanHuang

debug exception fastd

24/03 2017

v2.0.2

2.0.2.0

error handle component.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar JanHuang

debug exception fastd

29/12 2016

2.0.x-dev

2.0.9999999.9999999-dev

error handle component.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar JanHuang

debug exception fastd

29/12 2016

v2.0.1

2.0.1.0

error handle component.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar JanHuang

debug exception fastd

14/11 2016

3.0.x-dev

3.0.9999999.9999999-dev

error handle component.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar JanHuang

debug exception fastd

12/10 2016

1.0.x-dev

1.0.9999999.9999999-dev

debug handle component.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar JanHuang

debug exception fastd

12/10 2016

v1.0.7

1.0.7.0

debug handle component.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar JanHuang

debug exception fastd

13/06 2016

dev-master

9999999-dev

error handle component.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar JanHuang

debug exception fastd

13/06 2016

v2.0.0

2.0.0.0

error handle component.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar JanHuang

debug exception fastd

13/06 2016

v2.0.0-beta9

2.0.0.0-beta9

error handle component.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar JanHuang

debug exception fastd

11/06 2016

v2.0.0-beta8

2.0.0.0-beta8

error handle component.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar JanHuang

debug exception fastd

11/06 2016

v2.0.0-beta7

2.0.0.0-beta7

error handle component.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar JanHuang

debug exception fastd

10/06 2016

v2.0.0-beta6

2.0.0.0-beta6

error handle component.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar JanHuang

debug exception fastd

07/06 2016

v2.0.0-beta5

2.0.0.0-beta5

error handle component.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar JanHuang

debug exception fastd

07/06 2016

v2.0.0-beta4

2.0.0.0-beta4

error handle component.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar JanHuang

debug exception fastd

04/06 2016

v2.0.0-beta3

2.0.0.0-beta3

error handle component.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar JanHuang

debug exception fastd

12/05 2016

v2.0.0-beta2

2.0.0.0-beta2

error handle component.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar JanHuang

debug exception fastd

11/05 2016

v2.0.0-beta1

2.0.0.0-beta1

error handle component.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar JanHuang

debug exception fastd

25/12 2015

v1.0.6

1.0.6.0

debug handle component.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar JanHuang

debug exception fastd

26/08 2015

v1.0.5

1.0.5.0

debug handle component.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar JanHuang

debug exception fastd

25/08 2015

v1.0.4

1.0.4.0

debug handle component.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar JanHuang

debug exception fastd

18/08 2015

v1.0.3

1.0.3.0

debug handle component.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar JanHuang

debug exception fastd

14/08 2015

v1.0.2

1.0.2.0

debug handle component.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar JanHuang

debug exception fastd

08/08 2015

v1.0.1

1.0.1.0

debug handle component.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar JanHuang

debug exception fastd

08/08 2015

v1.0.0

1.0.0.0

debug handle component.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar JanHuang

debug exception fastd

08/08 2015

v1.0.0-BETA1

1.0.0.0-beta1

debug handle component.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar JanHuang

debug exception fastd

24/07 2015

v0.1.1

0.1.1.0

exception handle component.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar JanHuang

exception fastd

20/07 2015

v0.1.0

0.1.0.0

exception handle component.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar JanHuang

exception fastd