2017 © Pedro Peláez
 

symfony-bundle error-notifier-bundle

This bundle sends a html email when an error occurs.

image

elao/error-notifier-bundle

This bundle sends a html email when an error occurs.

  • Wednesday, June 27, 2018
  • by Elao
  • Repository
  • 21 Watchers
  • 59 Stars
  • 129,117 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 28 Forks
  • 6 Open issues
  • 14 Versions
  • 3 % Grown

The README.md

Elao ErrorNotifier Bundle

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

What is it?

This bundle sends an email each time there is a 500 error on the production server. You can also be notified of 404 or PHP fatal errors., (*2)

The email contains a lot of information: see the screenshot at the end of the README., (*3)

Installation

Symfony >= 2.1

Add this in your composer.json, (*4)

"require": {
    "elao/error-notifier-bundle" : "dev-master"
},

And run php composer.phar update elao/error-notifier-bundle, (*5)

Symfony 2.0.x

Add the followings lines to your deps file, (*6)

[ElaoErrorNotifierBundle]
    git=git://github.com/Elao/ErrorNotifierBundle.git
    target=bundles/Elao/ErrorNotifierBundle

and don't forget to register it in your autoloading app/autoload.php, (*7)

$loader->registerNamespaces(array(
    ...
    'Elao' => __DIR__.'/../vendor/bundles',
));

and finally run the vendors script:, (*8)

$ php bin/vendors install

Register the bundle in app/AppKernel.php

public function registerBundles()
{
    return array(
        // ...
        new Elao\ErrorNotifierBundle\ElaoErrorNotifierBundle(),
    );
}

Configuration

Add in your config_prod.yml file, you don't need error notifier when you are in dev environment., (*9)

# app/config/config_prod.yml
elao_error_notifier:
    from: from@example.com
    to: to@example.com
    handle404: true # default :  false
    handleHTTPcodes: ~
    mailer: your.mailer.id # default : mailer
    handlePHPErrors: true # catch fatal erros and email them
    handlePHPWarnings: true # catch warnings and email them
    handleSilentErrors: false # don't catch error on method with an @
    filteredRequestParams: [password] # replace request contents of parameter "password" with stars
    ignoredClasses: ~

How to setup another mailer for sending the error mail

The mailer option has been added to let the application send the error mail via local smtp instead of using the regular quota on 3rd mailer services., (*10)

For example, if you wish to use an custom mailer that send mails via your server mail transport, create this one in the config.yml of your project:, (*11)

# app/config/config.yml
swiftmailer:
    default_mailer: default
    mailers:
        default:
            transport: smtp
            host: localhost
            username: mylogin
            password: mypassword
        notifier:
            transport: mail

And after just change the mailer key on your config_prod.yml :, (*12)

# app/config/config_prod.yml
elao_error_notifier:
    mailer: swiftmailer.mailer.notifier

How to ignore errors raised by given classes ?

Sometimes, you want the bundle not to send email for errors raised by a given class. You can now do it by adding the name of the class raising the error in the ignored_class key., (*13)

# app/config/config_prod.yml
elao_error_notifier:
    ignoredClasses:
        - "Guzzle\\Http\\Exception\\ServerErrorResponseException"
        - ...

How to handle other HTTP errors by given error code ?

If you want the bundle to send email for other HTTP errors than 500 and 404, you can now specify the list of error codes you want to handle., (*14)

# app/config/config_prod.yml
elao_error_notifier:
    handleHTTPcodes:
        - 405
        - ...

How to avoid sending many same messages for one error ?

If an error occurs on a website with a lot of active visitors you'll get spammed by the notifier for the same error., (*15)

In order to avoid getting spammed, use the repeatTimeout option., (*16)

# app/config/config_prod.yml
elao_error_notifier:
    repeatTimeout: 3600

In this example, if an errors X occurs, and the same error X occurs again within 1 hour, you won't recieve a 2nd email., (*17)

Twig Extension

There are also some extensions that you can use in your Twig templates (thanks to Goutte)., (*18)

Extends Twig with:, (*19)

{{ "my string, whatever" | pre }}  --> wraps with 

<

pre>
{{ myBigVar | yaml_dump | pre }} as {{ myBigVar | ydump }} or {{ myBigVar | dumpy }}
{{ myBigVar | var_dump | pre }}  as {{ myBigVar | dump }}

You may control the depth of recursion with a parameter, say foo = array('a'=>array('b'=>array('c','d')))

{{ foo | dumpy(0) }} --> 'array of 1'
{{ foo | dumpy(2) }} -->
                           a:
                             b: 'array of 2'
{{ foo | dumpy(3) }} -->
                           a:
                             b:
                               - c
                               - d

Default value is 1 (MAX_DEPTH const)., (*20)

How to ignore sending HTTP errors if request comes from any of given IPs?

If you want to ignore sending HTTP errors if the request comes from specific IPs, you can now specify the list of ignored IPs., (*21)

# app/config/config_prod.yml
elao_error_notifier:
    ignoredIPs:
        - "178.63.45.100"
        - ...

How to ignore sending HTTP errors if the user agent match a given pattern?

For some reasons you may need to ignore sending notifications if request comes from some user agents. Often you will need to use this feature with annoying crawlers which uses artificial intelligence to generate URLs which may not exist in your site., (*22)

# app/config/config_prod.yml
elao_error_notifier:
    ignoredAgentsPattern: "(Googlebot|bingbot)"

How to ignore sending HTTP errors if the URI match a given pattern?

For example if you want to ignore all not exist images errors you may do something like that., (*23)

# app/config/config_prod.yml
elao_error_notifier:
    ignoredUrlsPattern: "\.(jpg|png|gif)"

How to filter sensitive data in request variables?

Sometimes you don't want to receive passwords or other sensitive data via email. With filteredRequestParams you can specify request variable names which should be replaced with stars. This works for named forms, too (e.g. myFormName[password])., (*24)

# app/config/config_prod.yml
elao_error_notifier:
    filteredRequestParams:
      - "password"
      - "creditCardNo"
      - "_token"

Screenshot

Email ErrorNotifier Bundle, (*25)

The Versions

27/06 2018

dev-master

9999999-dev http://github.com/Elao/ErrorNotifierBundle

This bundle sends a html email when an error occurs.

  Sources   Download

MIT

The Requires

 

bundle error notifier elao

10/10 2017

v1.0.12

1.0.12.0 http://github.com/Elao/ErrorNotifierBundle

This bundle sends a html email when an error occurs.

  Sources   Download

MIT

The Requires

 

bundle error notifier elao

30/08 2017

v1.0.11

1.0.11.0 http://github.com/Elao/ErrorNotifierBundle

This bundle sends a html email when an error occurs.

  Sources   Download

MIT

The Requires

 

bundle error notifier elao

28/06 2017

v1.0.10

1.0.10.0 http://github.com/Elao/ErrorNotifierBundle

This bundle sends a html email when an error occurs.

  Sources   Download

MIT

The Requires

 

bundle error notifier elao

27/06 2017

v1.0.9

1.0.9.0 http://github.com/Elao/ErrorNotifierBundle

This bundle sends a html email when an error occurs.

  Sources   Download

MIT

The Requires

 

bundle error notifier elao

23/01 2017

v1.0.8

1.0.8.0 http://github.com/Elao/ErrorNotifierBundle

This bundle sends a html email when an error occurs.

  Sources   Download

MIT

The Requires

 

bundle error notifier elao

21/12 2015

v1.0.7

1.0.7.0 http://github.com/Elao/ErrorNotifierBundle

This bundle send html mail when an error appear

  Sources   Download

MIT

The Requires

 

bundle error notifier elao

05/11 2015

v1.0.6

1.0.6.0 http://github.com/Elao/ErrorNotifierBundle

This bundle send html mail when an error appear

  Sources   Download

MIT

The Requires

 

bundle error notifier elao

09/10 2015

v1.0.5

1.0.5.0 http://github.com/Elao/ErrorNotifierBundle

This bundle send html mail when an error appear

  Sources   Download

MIT

The Requires

 

bundle error notifier elao

28/05 2015

v1.0.4

1.0.4.0 http://github.com/Elao/ErrorNotifierBundle

This bundle send html mail when an error appear

  Sources   Download

MIT

The Requires

 

bundle error notifier elao

18/12 2014

v1.0.3

1.0.3.0 http://github.com/Elao/ErrorNotifierBundle

This bundle send html mail when an error appear

  Sources   Download

MIT

The Requires

 

bundle error notifier elao

25/02 2014

v1.0.2

1.0.2.0 http://github.com/Elao/ErrorNotifierBundle

This bundle send html mail when an error appear

  Sources   Download

MIT

The Requires

 

bundle error notifier elao

16/10 2013

v1.0.1

1.0.1.0 http://github.com/Elao/ErrorNotifierBundle

This bundle send html mail when an error appear

  Sources   Download

MIT

The Requires

 

bundle error notifier elao

17/01 2013

v1.0.0

1.0.0.0 http://github.com/Elao/ErrorNotifierBundle

This bundle send html mail when an error appear

  Sources   Download

MIT

The Requires

 

bundle error notifier elao