nickshek / laravel-request
A simple package to log all the requests in a database for Laravel 5
Requires
- php: >=5.5.0
- laravel/framework: ^5.0
Requires (Dev)
- orchestra/testbench: ^3.2
- phpunit/phpunit: 4.8.*
- scrutinizer/ocular: ^1.3
This package is not auto-updated.
Last update: 2024-12-21 21:19:52 UTC
README
A simple package to log all the requests in a database for Laravel 5.
Inspired by django-request
Note: This package is still very alpha!
Install
You can install the package via composer:
composer require nickshek/laravel-request
Install service provider
// config/app.php 'providers' => [ ... LaravelRequest\LaravelRequestServiceProvider::class, ];
publish migrations and config file
php artisan vendor:publish --provider="LaravelRequest\LaravelRequestServiceProvider"
Afterwards you can edit the file config/laravel-request.php
to suit your needs.
Run migration to create required tables
php artisan migrate
By default, the middleware \LaravelRequest\Middleware\LogAfterRequest::class
enables logging on all pages. You'll probably want to inherit your own class containing you application's logging rule handler.
namespace App\Http\Middleware; // app/Http/Middleware/LogAfterRequestExceptAdmin.php use LaravelRequest\Middleware\LogAfterRequest; class LogAfterRequestExceptAdmin extends LogAfterRequest { /** * @return bool */ protected function shouldLogRequest($request, $response) { return $request->segment(1) !== 'admin'; } }
Next, simply register the newly created class in your middleware stack.
// app/Http/Kernel.php class Kernel extends HttpKernel { protected $middleware = [ // ... \App\Http\Middleware\LogAfterRequestExceptAdmin::class, ]; // ... }
That's it!
License
The MIT License (MIT). Please see License File for more information.