mirror of
https://github.com/filp/whoops.git
synced 2026-09-02 13:38:43 +00:00
+1
-3
@@ -1,9 +1,7 @@
|
||||
language: php
|
||||
|
||||
php:
|
||||
- 5.3.3
|
||||
- 5.3
|
||||
- 5.4
|
||||
- 5.5.9
|
||||
- 5.5
|
||||
- 5.6
|
||||
- 7.0
|
||||
|
||||
@@ -17,12 +17,6 @@ PHP errors for cool kids
|
||||
error interface that helps you debug your web projects, but at heart it's a simple yet
|
||||
powerful stacked error handling system.
|
||||
|
||||
## Major version bump
|
||||
|
||||
**This is documentation for upcoming Whoops version 2**.
|
||||
It is currently in its pre-release state, available with a separate, [pre-release download tag](https://packagist.org/packages/filp/whoops#dev-master).
|
||||
For documentation on the stable version, see [branch `v1`](https://github.com/filp/whoops/tree/v1).
|
||||
|
||||
## Features
|
||||
|
||||
- Flexible, stack-based error handling
|
||||
@@ -40,7 +34,7 @@ If you use Laravel 4, you already have Whoops. There are also community-provided
|
||||
[Silex 2](https://github.com/texthtml/whoops-silex),
|
||||
[Phalcon](https://github.com/whoops-php/phalcon),
|
||||
[Laravel 3](https://gist.github.com/hugomrdias/5169713#file-start-php),
|
||||
[Laravel 5](https://mattstauffer.co/blog/bringing-whoops-back-to-laravel-5),
|
||||
[Laravel 5](https://github.com/GrahamCampbell/Laravel-Exceptions),
|
||||
[CakePHP 2](https://github.com/oldskool/WhoopsCakephp/tree/cake2),
|
||||
[CakePHP 3](https://github.com/oldskool/WhoopsCakephp),
|
||||
[Zend Framework 2](https://github.com/ghislainf/zf2-whoops),
|
||||
|
||||
+3
-6
@@ -12,10 +12,10 @@
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.3.3",
|
||||
"phpunit/phpunit": "^4.8"
|
||||
"php": ">=5.5.9"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^4.8 || ^5.0",
|
||||
"mockery/mockery": "0.9.*"
|
||||
},
|
||||
"suggest": {
|
||||
@@ -25,10 +25,7 @@
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Whoops\\": "src/Whoops/"
|
||||
},
|
||||
"files": [
|
||||
"src/Whoops/functions.php"
|
||||
]
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
|
||||
+10
-10
@@ -13,8 +13,8 @@
|
||||
- [`Whoops\Handler\PrettyPageHandler`](#handler-pretty) - Outputs a detailed, fancy error page
|
||||
|
||||
### Core Functions:
|
||||
- [`Whoops\isAjaxRequest()`](#fn-ajax) - Determines whether the current request was triggered by XMLHttpRequest
|
||||
- [`Whoops\isCommandLine()`](#fn-cli) - Determines whether the current request was triggered via php commandline interface (CLI)
|
||||
- [`Whoops\Util\Misc::isAjaxRequest()`](#fn-ajax) - Determines whether the current request was triggered by XMLHttpRequest
|
||||
- [`Whoops\Util\Misc::isCommandLine()`](#fn-cli) - Determines whether the current request was triggered via php commandline interface (CLI)
|
||||
|
||||
|
||||
# Core Classes:
|
||||
@@ -407,23 +407,23 @@ PrettyPageHandler::handle()
|
||||
|
||||
# Core Functions:
|
||||
|
||||
## <a name="fn-ajax"></a> `Whoops\isAjaxRequest()`
|
||||
## <a name="fn-ajax"></a> `Whoops\Util\Misc::isAjaxRequest()`
|
||||
#=> boolean
|
||||
|
||||
```php
|
||||
// Use a certain handler only in AJAX triggered requests
|
||||
if (Whoops\isAjaxRequest()){
|
||||
$run->addHandler($myHandler)
|
||||
if (Whoops\Util\Misc::isAjaxRequest()){
|
||||
$run->addHandler($myHandler);
|
||||
}
|
||||
```
|
||||
|
||||
## <a name="fn-cli"></a> `Whoops\isCommandLine()`
|
||||
## <a name="fn-cli"></a> `Whoops\Util\Misc::isCommandLine()`
|
||||
#=> boolean
|
||||
|
||||
```php
|
||||
// Use a certain handler only in php cli
|
||||
if (Whoops\isCommandLine()){
|
||||
$run->addHandler($myHandler)
|
||||
if (Whoops\Util\Misc::isCommandLine()){
|
||||
$run->addHandler($myHandler);
|
||||
}
|
||||
```
|
||||
|
||||
@@ -437,5 +437,5 @@ $plainTextHandler = new PlainTextHandler();
|
||||
if (!Whoops\isCommandLine()){
|
||||
$plainTextHandler->loggerOnly(true);
|
||||
}
|
||||
$run->addHandler($myHandler)
|
||||
```
|
||||
$run->addHandler($myHandler);
|
||||
```
|
||||
|
||||
@@ -157,10 +157,10 @@ class Inspector
|
||||
*
|
||||
* If xdebug is installed
|
||||
*
|
||||
* @param Exception $e
|
||||
* @param \Throwable $exception
|
||||
* @return array
|
||||
*/
|
||||
protected function getTrace(\Exception $e)
|
||||
protected function getTrace($e)
|
||||
{
|
||||
$traces = $e->getTrace();
|
||||
|
||||
|
||||
@@ -29,6 +29,10 @@
|
||||
$start = key($range) + 1;
|
||||
$code = join("\n", $range);
|
||||
?>
|
||||
<style>#frame-code-0 .linenums li:nth-child(<?= $line-$start+1 ?>) {
|
||||
/* Style current line */
|
||||
background-color: hsl(0, 0%, 33%);
|
||||
}</style>
|
||||
<pre class="code-block prettyprint linenums:<?php echo $start ?>"><?php echo $tpl->escape($code) ?></pre>
|
||||
<?php endif ?>
|
||||
<?php endif ?>
|
||||
|
||||
@@ -23,6 +23,22 @@ class Misc
|
||||
return isset($_SERVER["REQUEST_URI"]) && !headers_sent();
|
||||
}
|
||||
|
||||
public static function isAjaxRequest()
|
||||
{
|
||||
return (
|
||||
!empty($_SERVER['HTTP_X_REQUESTED_WITH'])
|
||||
&& strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest');
|
||||
}
|
||||
|
||||
/**
|
||||
* Check, if possible, that this execution was triggered by a command line.
|
||||
* @return bool
|
||||
*/
|
||||
public static function isCommandLine()
|
||||
{
|
||||
return PHP_SAPI == 'cli';
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate ErrorException code into the represented constant.
|
||||
*
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: staabm
|
||||
* Date: 21.11.2015
|
||||
* Time: 16:08
|
||||
*/
|
||||
|
||||
namespace Whoops;
|
||||
|
||||
function isAjaxRequest()
|
||||
{
|
||||
return (
|
||||
!empty($_SERVER['HTTP_X_REQUESTED_WITH'])
|
||||
&& strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest');
|
||||
}
|
||||
|
||||
/**
|
||||
* Check, if possible, that this execution was triggered by a command line.
|
||||
* @return bool
|
||||
*/
|
||||
function isCommandLine()
|
||||
{
|
||||
return PHP_SAPI == 'cli';
|
||||
}
|
||||
@@ -44,6 +44,23 @@ class InspectorTest extends TestCase
|
||||
$this->assertSame($outer->getLine(), $frames[0]->getLine());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Whoops\Exception\Inspector::getFrames
|
||||
*/
|
||||
public function testDoesNotFailOnPHP7ErrorObject()
|
||||
{
|
||||
if (!class_exists('Error')) {
|
||||
$this->markTestSkipped(
|
||||
'PHP 5.x, the Error class is not available.'
|
||||
);
|
||||
}
|
||||
|
||||
$inner = new \Error('inner');
|
||||
$outer = $this->getException('outer', 0, $inner);
|
||||
$inspector = $this->getInspectorInstance($outer);
|
||||
$frames = $inspector->getFrames();
|
||||
$this->assertSame($outer->getLine(), $frames[0]->getLine());
|
||||
}
|
||||
/**
|
||||
* @covers Whoops\Exception\Inspector::getExceptionName
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user