Larax is laravel package help us to log exceptions happened in our laravel applications and notify us with all the data we need to find out the cause of the problem when exception happened such as (the data did user sent it in body, headers ,user ip , user id and his guard) .
Add this package in composer.json.
{
"require": {
"escode/larax": "1.*"
}
}
or run in terminal:
composer require escode/larax
open "/config/app.php" and append Escode\Larax\LaraxServiceProvider::class to providers array
Example
'providers' => [
Escode\Larax\LaraxServiceProvider::class,
php artisan vendor:publish --tag=larax-config
php artisan migrate
going to "/app/Exceptions/Handler.php" and make it extends from Escode\Larax\ExceptionHandler
Example
use Escode\Larax\ExceptionHandler;
class Handler extends ExceptionHandler
{
open "/config/larax.php" this file help you to easily configure and control Larax.
You can ignore some keys “remove it from headers data” from request headers such as “Authorization”.
You can ignore some fields “remove it from body data” from request body or query string such as “password , image , token”.
return [
//set your middleware that's allow to access exceptions pages on website
'middleware'=>'auth',
//api middleware
'ApiMiddleware'=>'AuthLaraxApi',
//exceptions data you want to store it
'exception_data'=>[
'ip'=>true,
'url'=>true,
'headers'=>true,
'body'=>true,
],
// Note: if you enable detect user in exception larax will push StartSession::class and EncryptCookies::class in $middleware Kernel.php
// and you should be comment StartSession::class from $middlewareGroups => web
'detect_user'=>false,
//array of guards names will use it for detect user id
'guards'=>['auth'],
//ignore fields in request headers (this fields not saved in db)
'ignore_headers'=>[
'Authorization','cookie'
],
//ignore fields in request (this fields not saved in db)
'ignore_inputs'=>[
'image','password','password_confirmation'
],
//send email when exception happened
//enable send emails
'enable_email'=>true,
//email list you want send notify them with exception data
'emails'=>[
//example
//'es.code@yahoo.com',
],
]
open "http://localhost:8000/larax/exceptions" to see the exceptions did happened in your application.
users in larax is used to allow users to read exceptions using Larax Api.
you can read your application exceptions data over Api just do "GET" request to "http://localhost:8000/api/larax/exceptions" using user key as bearer token