Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP 8.0 support 🚀 and more (#78) #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
language: php

php:
- 7.2
- 7.2
- 7.3
- 7.4
- 8.0snapshot

env:
matrix:
# - COMPOSER_FLAGS="--prefer-lowest"
- COMPOSER_FLAGS=""
matrix:
- COMPOSER_FLAGS=""

before_script:
- travis_retry composer self-update
- travis_retry composer update ${COMPOSER_FLAGS} --no-interaction
- travis_retry composer self-update
- travis_retry composer update ${COMPOSER_FLAGS} --no-interaction --prefer-dist

# script:
# - vendor/bin/phpunit --coverage-clover build/logs/clover.xml
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

All notable changes to `LERN` will be documented in this file.

### Unreleased
- Updated for Laravel 7 and 8
- Add support for PHP 7.3, 7.4, 8.0
- Removed support for Laravel 5.5, 5.6, 5.7, 5.8
- Removed support for PHP 7.0, 7.1
- Removed deprecated RavenHandler handler, use sentry/sentry 3.x and their Sentry\Monolog\Handler instead
- Removed deprecated HipChat handler, migrate to Slack and use SlackWebhookHandler or SlackHandler instead

### 5.0.0
- Updated for Laravel 6

Expand Down
27 changes: 15 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@ Currently supported notification channels via [Monolog](https://github.com/Selda
- Email
- [Pushover](https://pushover.net/)
- [Slack](https://slack.com/)
- [Hipchat](https://www.hipchat.com/)
- [Fleephook](https://fleep.io/)
- [Flowdock](https://www.flowdock.com/)
- [Plivo](https://www.plivo.com/) an SMS messaging service.
- [Twilio](https://www.twilio.com/) an SMS messaging service.
- [Sentry](https://getsentry.com) via [Raven](https://github.com/getsentry/raven-php)
- [Sentry](https://getsentry.com) via [Sentry SDK for PHP](https://github.com/getsentry/sentry-php)
- [Mailgun](https://mailgun.com)

## Version Compatibility
Expand All @@ -32,15 +31,17 @@ Currently supported notification channels via [Monolog](https://github.com/Selda
5.4.x | 3.x
5.5.x | 4.x
5.6.x | 4.x
6.x | 5.x
6.x | 5.x and 6.x
7.x | 6.x
8.x | 6.x

## Migrating from `3.x` to `4.x`
Make sure that the config file now includes the new `lern.notify.class` and `lern.record.class` settings. Check the [config file](https://github.com/tylercd100/lern/blob/master/config/lern.php) to see how they are used.

## Migrating from `2.x` to `3.x`
Version 3.x introduces the ability to collect more information from the error such as the user_id, url, method, and input data. In order to use 3.x you will need to copy over the new [config file](https://github.com/tylercd100/lern/blob/master/config/lern.php), the migration file and then migrate it.
```php
# This will only copy over the migration file. For the config file you can either include the --force flag (Which will overwrite it) or copy it manually from github
# This will only copy over the migration file. For the config file you can either include the --force flag (Which will overwrite it) or copy it manually from github
php artisan vendor:publish --provider="Tylercd100\LERN\LERNServiceProvider"
php artisan migrate
```
Expand All @@ -59,18 +60,18 @@ Then you will need to run these commands in the terminal in order to copy the co
php artisan vendor:publish --provider="Tylercd100\LERN\LERNServiceProvider"
```

Before you run the migration you may want to take a look at `config/lern.php` and change the `table` property to a table name that you would like to use. After that run the migration
Before you run the migration you may want to take a look at `config/lern.php` and change the `table` property to a table name that you would like to use. After that run the migration
```bash
php artisan migrate
```

## Usage
To use LERN modify the report method in the `app/Exceptions/Handler.php` file
```php
public function report(Exception $e)
public function report(Throwable $e)
{
if ($this->shouldReport($e)) {

//Check to see if LERN is installed otherwise you will not get an exception.
if (app()->bound("lern")) {
app()->make("lern")->handle($e); //Record and Notify the Exception
Expand All @@ -82,17 +83,19 @@ public function report(Exception $e)
*/
}
}

return parent::report($e);
}
```

Dont forget to add this to the top of the file
Dont forget to add this to the top of the file
```php
//If you updated your aliases array in "config/app.php"
use LERN;
use Throwable;
//or if you didnt...
use Tylercd100\LERN\Facades\LERN;
use Throwable;
```

### Recording
Expand Down Expand Up @@ -143,7 +146,7 @@ LERN uses the Monolog library to send notifications. If you need more than the s
#### Changing the log level programmatically
Some notification services support different log levels. If changing the config value `lern.notify.log_level` is not enough then try it this way:
```php
// Change the log level.
// Change the log level.
// Default is: critical
// Options are: debug, info, notice, warning, error, critical, alert, emergency
LERN::setLogLevel("emergency");
Expand Down Expand Up @@ -176,8 +179,8 @@ Make sure that you set the view config value to null or the `LERN::setMessage()`
#### Custom Monolog Handlers
To use a custom Monolog Handler call the `pushHandler` method
```php
use Monolog\Handler\HipChatHandler;
$handler = new HipChatHandler($token,$room);
use Monolog\Handler\SlackHandler;
$handler = new SlackHandler($token, $channel);
LERN::pushHandler($handler);
LERN::notify($exception);
```
Expand Down
23 changes: 11 additions & 12 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,19 @@
"Tylercd100\\LERN\\Tests\\": "tests/"
}
},
"minimum-stability": "stable",
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"php": "^7.2",
"illuminate/support": "^6.0",
"monolog/monolog": "^1.22",
"tylercd100/laravel-notify": "^3.0"
"php": "^7.2|^8.0",
"illuminate/support": "^6.0|^7.0|^8.0",
"monolog/monolog": "^2.0",
"tylercd100/laravel-notify": "^4.0"
},
"require-dev": {
"orchestra/testbench": "^4.0",
"phpunit/phpunit": "^8.0",
"doctrine/dbal": "~2.3"
"mockery/mockery": "~1.3.3|^1.4.2",
"orchestra/testbench": "^4.0|^5.0|^6.0",
"phpunit/phpunit": "^8.4|^9.3.3",
"doctrine/dbal": "^2.6|^3.0"
},
"suggest": {
},
Expand All @@ -52,8 +54,5 @@
"LERN": "Tylercd100\\LERN\\Facades\\LERN"
}
}
},
"repositories": [

]
}
}
38 changes: 14 additions & 24 deletions config/lern.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

return [

/**
* To avoid infinite loops that generate thousands of records/notifications in an instant
/**
* To avoid infinite loops that generate thousands of records/notifications in an instant
* Please make sure you use a Cache driver that is persistant such as redis, memcache, file, etc
*
*
* Value is in seconds.
*/
'ratelimit' => 1,
'ratelimit' => 1,

'record'=>[
/**
Expand All @@ -30,7 +30,7 @@
* Database table to use
*/
'table'=>'vendor_tylercd100_lern_exceptions',

/**
* Information to store
*/
Expand Down Expand Up @@ -71,12 +71,12 @@
* The log level to use when notifying
*/
'log_level' => 'critical', //Options are: debug, info, notice, warning, error, critical, alert, emergency.

/**
* When using the default message body this will also include the stack trace
*/
'includeExceptionStackTrace' => true,

/**
* mail, pushover, slack, etc...
*/
Expand Down Expand Up @@ -120,20 +120,17 @@
],

/**
* HipChat settings
* Flowdock settings
*/
'hipchat'=>[
'token' => env('HIPCHAT_APP_TOKEN'),
'room' => 'room',
'name' => 'name',
'notify'=> true,
'flowdock'=>[
'token' => env('FLOWDOCK_APP_TOKEN'),
],

/**
* Flowdock settings
* Sentry settings
*/
'flowdock'=>[
'token' => env('FLOWDOCK_APP_TOKEN'),
'sentry'=>[
'dsn' => env('SENTRY_DSN'),
],

/**
Expand Down Expand Up @@ -161,14 +158,7 @@
'secret' => env('TWILIO_AUTH_SECRET'),
'to' => env('TWILIO_TO'),
'from' => env('TWILIO_FROM'),
],

/**
* Raven settings
*/
'raven'=>[
'dsn' => env('RAVEN_DSN'),
]
],

];
10 changes: 5 additions & 5 deletions src/Components/Component.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Tylercd100\LERN\Components;

use Exception;
use Throwable;
use Illuminate\Support\Facades\Cache;
use Carbon\Carbon;

Expand All @@ -23,10 +23,10 @@ abstract class Component {
/**
* Determine if the exception is in the "do not handle" list.
*
* @param \Exception $e
* @param \Throwable $e
* @return bool
*/
protected function shouldntHandle(Exception $e) {
protected function shouldntHandle(Throwable $e) {
$dontHandle = array_merge($this->dontHandle, $this->absolutelyDontHandle);

foreach ($dontHandle as $type) {
Expand All @@ -46,10 +46,10 @@ protected function shouldntHandle(Exception $e) {
/**
* Returns the cache key for the exception with the current component
*
* @param \Exception $e
* @param \Throwable $e
* @return string
*/
protected function getCacheKey(Exception $e)
protected function getCacheKey(Throwable $e)
{
return "LERN::".static::class."::".get_class($e);
}
Expand Down
Loading