Giter VIP home page Giter VIP logo

laravel-error-emailer's Introduction

The Monkeys

Laravel Error Emailer

Don't have a sysadmin keeping an eye on your application's error logs? Just add this package to your Laravel application and you'll be sent an email with plenty of diagnostic information whenever an error occurs.

Installation Laravel 4.x

To get the latest version of the package simply require it in your composer.json file.

composer require themonkeys/error-emailer:dev-master --no-update
composer update themonkeys/error-emailer

Once the package is installed you need to register the service provider with the application. Open up app/config/app.php and find the providers key.

'providers' => array(
    'Themonkeys\ErrorEmailer\ErrorEmailerServiceProvider',
)

Add the following to the facades key:

'facades' => array(
    'ErrorEmailer' => 'Themonkeys\ErrorEmailer\Facades\ErrorEmailer',
)

The package comes disabled by default, since you probably don't want error emailing enabled on your development environment. Especially if you've set 'debug' => true,.

To configure the package, you can use the following command to copy the configuration file to app/config/packages/themonkeys/error-emailer.

php artisan config:publish themonkeys/error-emailer

Or you can just create a new file in that folder and only override the settings you need.

The settings themselves are documented inside config.php. A minimal config file to enable error emails and set two recipients can be as simple as:

<?php
return array(
    'enabled' => true,
    'to' => array(
        array('address' => '[email protected]', 'name' => 'Your Name'),
        array('address' => '[email protected]', 'name' => 'My Name'),
    ),
);

To make your configuration apply only to a particular environment, put your configuration in an environment folder such as app/config/packages/themonkeys/error-emailer/environment-name/config.php.

Configuring emails

For the error emails to be sent, your application needs to be properly configured to send email. Open your app/config/mail.php file to configure default settings, and override those defaults for your application's other environments by adding app/config/<environment>/mail.php files as necessary. In particular, make sure you've set up a default sender address - without one, the error emailer won't be able to send emails:

    'from' => array('address' => '[email protected]', 'name' => 'My Application'),

Error handler precedence

This package intercepts errors in the same way as your application can, by registering an error handler with the application. The default Laravel application includes an empty error handler in app/start/global.php:

App::error(function(Exception $exception, $code)
{
	Log::error($exception);
});

Because of the way App::error() works, this handler is called before this package's handler; so if you return a response from the handler in app/start/global.php (for example to render a custom error page), you won't receive any error emails. To fix this, our recommended approach is to change the priority of the handler in app/start/global.php so that it runs last instead of first:

App::pushError(function(Exception $exception, $code)
{
	return View::make('myerrorpage', array(
	    'exception' => $exception,
	    'code' => $code,
    ));
});

(Note the change from App::error to App::pushError).

Contribute

In lieu of a formal styleguide, take care to maintain the existing coding style.

License

MIT License (c) The Monkeys

laravel-error-emailer's People

Contributors

ch4r1y avatar felthy avatar jonasva avatar semgovaert avatar taledo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

laravel-error-emailer's Issues

Email throttling?

Is there a way to make it so you get only one email per X minutes (like once an hour) that contains all the errors during that timeframe?

Not receiving mails

What is incorrect over here, that is it not sending e-mails:
Path:
app / config / packages / themonkeys / error-emailer / config.php

<?php
return array(
    /*
    |--------------------------------------------------------------------------
    | Enable emailing errors
    |--------------------------------------------------------------------------
    |
    | Should we email error traces?
    |
    */
    'enabled' => true,

    /*
    |--------------------------------------------------------------------------
    | Skip emailing errors for some HTTP status codes
    |--------------------------------------------------------------------------
    |
    | For which HTTP status codes should we NOT send error emails?
    |
    */
    'disabledStatusCodes' => array(
        '404' => true,
    ),

    /*
    |--------------------------------------------------------------------------
    | Error email recipients
    |--------------------------------------------------------------------------
    |
    | Email stack traces to these addresses.
    |
    | For a single recipient, the format can just be
    |   'to' => array('address' => '[email protected]', 'name' => 'Your Name'),
    |
    | For multiple recipients, just specify an array of those:
    |   'to' => array(
    |       array('address' => '[email protected]', 'name' => 'Your Name'),
    |       array('address' => '[email protected]', 'name' => 'My Name'),
    |   ),
    |
    */

    'to' => [
           ['address' => '[email protected]', 'name' => 'xx'],
           ['address' => '[email protected]', 'name' => 'xx'],
    ],
);

And / app / config / packages / themonkeys / error-emailer / local / config.php
with enabled to false:

<?php
return array(
    /*
    |--------------------------------------------------------------------------
    | Enable emailing errors
    |--------------------------------------------------------------------------
    |
    | Should we email error traces?
    |
    */
    'enabled' => false, 

    /*
    |--------------------------------------------------------------------------
    | Skip emailing errors for some HTTP status codes
    |--------------------------------------------------------------------------
    |
    | For which HTTP status codes should we NOT send error emails?
    |
    */
    'disabledStatusCodes' => array(
        '404' => true,
    ),

    /*
    |--------------------------------------------------------------------------
    | Error email recipients
    |--------------------------------------------------------------------------
    |
    | Email stack traces to these addresses.
    |
    | For a single recipient, the format can just be
    |   'to' => array('address' => '[email protected]', 'name' => 'Your Name'),
    |
    | For multiple recipients, just specify an array of those:
    |   'to' => array(
    |       array('address' => '[email protected]', 'name' => 'Your Name'),
    |       array('address' => '[email protected]', 'name' => 'My Name'),
    |   ),
    |
    */

    'to' => array('address' => null, 'name' => null),
);

Minor typo :)

Your readme.md file says this in the installation section:

To get the latest version of cachebuster simply require it in your composer.json file.

I think you meant to replace that cachebuster reference, yes?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.