The amgSentryPlugin
is a Symfony 1.4 plugin for the Sentry PHP client.
This plugin is based on the Sentry PHP client library sentry-php.
- PHP ≥ 5.2
- symfony ≥ 1.4
- Sentry instance
In the plugins
folder of your symfony project.
Add the require to your composer.json. It's oddly named but like this Composer's symfony1 installer camelcases it correctly. Composer will install it into your project's plugins directory automatically, and add the requirements.
{
"config": {
"vendor-dir": "lib/vendor"
},
"require": {
"amg-dev/amg-sentry-plugin": "dev-master"
}
}
Of course, don't forget to add Composer's autoloader to your ProjectConfiguration:
// config/ProjectConfiguration.class.php
require __DIR__ .'/../lib/vendor/autoload.php';
require_once dirname(__FILE__) .'/../lib/vendor/symfony/lib/autoload/sfCoreAutoload.class.php';
sfCoreAutoload::register();
class ProjectConfiguration extends sfProjectConfiguration
{
public function setup()
{
$this->enablePlugins(array(
'amgSentryPlugin',
...
));
// mandatory because of the Composer vendor directory naming scheme
sfConfig::set('sf_sentry_path', sfConfig::get('sf_lib_dir') . '/vendor/sentry/sentry');
}
}
$ git clone git@github.com:amg-dev/symfony-amg-sentry-plugin.git plugins/amgSentryPlugin
$ cd plugins/amgSentryPlugin
$ git submodule update --init
$ git submodule add github.com:amg-dev/symfony-amg-sentry-plugin.git plugins/amgSentryPlugin
$ git submodule update --init --recursive
Download and extract zip archive.
In your symfony project folder.
class ProjectConfiguration extends sfProjectConfiguration
{
public function setup()
{
$this->enablePlugins(array(
'sfDoctrinePlugin',
'amgSentryPlugin',
'...'
));
}
}
prod:
amg_sentry:
enabled: true
dsn: 'http://public:secret@sentry.example.com:9000/[PROJECT_ID]'
logger: 'custom-logger-name'
reportPHPErrors: true
reportPHPWarnings: false
report404: false
dsn
- If it is possible for sites with high traffic use UDP protocol.reportPHPErrors
- If true, it sends a notification when there is a exception.reportPHPWarnings
- If true, it sends a notification when there is a warning.report404
- If true, it sends a notification when a user lands on a page 404. It should be used only for the duration of the study, the risk is that web crawlers will produce a lot of notifications.
.settings:
standard_helpers: [default, Sentry, ...]
prod:
logger:
param:
loggers:
amg_sentry_logger:
class: amgSentryLogger
param:
level: warning
Additional docs about logging:
$ symfony cc
// send a message with no description and information level (by default)
amgSentry::sendMessage('Message title');
// send a debug message
amgSentry::sendMessage('Debug message title', 'Debug message description', amgSentry::DEBUG);
// send a warning message
amgSentry::sendMessage('Warning message title', 'Warning message description', amgSentry::WARNING);
// send an error message
amgSentry::sendMessage('Error message title', 'Error message description', amgSentry::ERROR);
// send an exception
amgSentry::sendException(new Exception('Exception message'), 'Exception description');
// set logger
amgSentry::setLogger('new-logger');
// reset logger
amgSentry::resetLogger();
// send a message with no description and information level (by default)
sentry_send_message('Message title');
// send a debug message
sentry_send_message('Debug message title', 'Debug message description', amgSentry::DEBUG);
// send a warning message
sentry_send_message('Warning message title', 'Warning message description', amgSentry::WARNING);
// send an error message
sentry_send_message('Error message title', 'Error message description', amgSentry::ERROR);
// send an exception
sentry_send_exception(new Exception('Exception message'), 'Exception description');
// set logger
sentry_set_logger('new-logger');
// reset logger
sentry_reset_logger();
// log a debug message
sfContext::getInstance()->getLogger()->debug('Debug message');
// log an error message
sfContext::getInstance()->getLogger()->err('Error message');
- Nicolas Dubois nicolas.c.dubois@gmail.com
- Jean Roussel contact@jean-roussel.fr
- Arkadiusz Tułodziecki atulodzi@gmail.com
The Sentry PHP client is maintained by the Sentry Team.