Created
April 30, 2014 08:00
-
-
Save bwaidelich/bda3dfd13eb3609a8ace to your computer and use it in GitHub Desktop.
Using Sentry for tracking errors in TYPO3 Flow
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "your/package", | |
"type": "typo3-flow-package", | |
// ... | |
"require": { | |
"raven/raven": "*" | |
}, | |
// ... | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Your\Package\Error; | |
/* * | |
* This script belongs to the TYPO3 Flow package "Your.Package". * | |
* * | |
* */ | |
use TYPO3\Flow\Error\ProductionExceptionHandler; | |
/** | |
* Production Exception handler that reports exceptions to a configurable Sentry DSN using the raven library | |
*/ | |
class SentryExceptionHandler extends ProductionExceptionHandler { | |
/** | |
* @param \Exception $exception | |
* @return void | |
*/ | |
protected function echoExceptionWeb(\Exception $exception) { | |
if (isset($this->options['sentryDsn']) && strlen($this->options['sentryDsn']) > 0) { | |
$ravenClient = new \Raven_Client($this->options['sentryDsn']); | |
$ravenClient->captureException($exception); | |
} | |
parent::echoExceptionWeb($exception); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TYPO3: | |
Flow: | |
error: | |
exceptionHandler: | |
className: 'Your\Package\Error\SentryExceptionHandler' | |
# Sentry DSN (e.g. "http://public:secret@example.com/1") | |
'sentryDsn': '' |
Loading of \Raven_Client doesn't work and resulting with a PHP fatal error:
"Fatal error: Class 'Raven_Client' not found in /path/to/My.Package/Classes/My/Package/Error/SentryExceptionHandler.php on line 24"
raven package is correctly installed with composer.
any idea?
I can't test this atm because we switched to Graylog2, maybe this helps:
TYPO3:
Flow:
# disable reflection for non psr-0 compliant 3rd party packages
object:
excludeClasses:
'raven.raven': ['.*']
FYI via twitter:
when using „composer install -o“ instead of „composer install“, class loading of \Raven_Client works fine
the excludeClasses setting has no effect. only "composer install -o" works
FYI: I still have the autoloading issue on Flow master (3.0). It can be worked around by including the raven autoloader explicitly:
include_once Files::concatenatePaths(array(FLOW_PATH_PACKAGES, 'Libraries/raven/raven/lib/Raven/Autoloader.php'));
\Raven_Autoloader::register();
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note: Sentry is a third party tool that allows remote tracking of exceptions. See https://getsentry.com