shoesten-tag / log-http
Log HTTP requests and responses in Laravel applications using PHP attributes
Installs: 4
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 0
Open Issues: 0
Type:package
Requires
- php: ^8.1
README
Log HTTP requests and responses in Laravel applications using PHP attributes.
How to install
composer require shoesten-tag/log-http --dev
Notes
-
The default setting for both request and response logging is false. You can enable both by setting them to true or enable only one of them as needed.
-
Currently, logging is done only in the Laravel log file. However, if you change the logging channel, logs will be sent to the specified channel instead.
-
Not recommended for production use!
How to use
Add middleware to your routes
//Example Route::resource('/dashboard', DashboardController::class)->middleware('log-http');
Log the response within the method
#[Intercept(response: true)] public function index(){ return new Collection(Employee::all()); }
Log the request within the method
#[Intercept(request: true)] public function index(){ return new Collection(Employee::all()); }
Enable logging of requests and responses within the class
#[Intercept(request: true, response: true)] class EmployeeController extends Controller { public function index(){ return new Collection(Employee::all()); } }