Home > Backend Development > PHP Tutorial > PHP Version of console.log() for Laravel

PHP Version of console.log() for Laravel

PHPz
Release: 2024-07-18 05:36:20
Original
1109 people have browsed it

Easily stream your Laravel application logs to the browser console tab (console.log) in real-time using server-sent event (SSE)

Welcome to Laravel Console Log (LCL)! This package brings real-time logging to your Laravel application, allowing you to stream your logs directly to your browser's console. Perfect for backend developers who want the power of console.log for their PHP projects. Say goodbye to tedious log file hunting and hello to instant insights!

PHP Version of console.log() for Laravel


✨ Features

  • Stream Backend Events: Send messages from Controllers, Events, Models, etc., directly to your browser console.
  • Stream Application Logs: View your Laravel logs (storage/logs/laravel.log) in real-time in your browser console.

Requirements

  • PHP >= 7
  • Laravel >= 5

Installation - Via Composer (Dev Environment)

Not recommended for production.

composer require --dev saasscaleup/laravel-console-log
Copy after login

For Laravel

Add the Service Provider to config/app.php in the providers section:

Saasscaleup\LCL\LCLServiceProvider::class,
Copy after login

Add the Facade to config/app.php in the aliases section:

'LCL' => Saasscaleup\LCL\Facades\LCLFacade::class,
Copy after login

Configuration

Publish Config, Migration, and View Files

php artisan vendor:publish --provider="Saasscaleup\LCL\LCLServiceProvider"
Copy after login

Run Migration

Create the stream_console_logs table:

php artisan migrate
Copy after login

Setup LCL in Your View/Layout

Add this to your main view/layout (usually layout/app.blade.php) file before

The above is the detailed content of PHP Version of console.log() for Laravel. For more information, please follow other related articles on the PHP Chinese website!

source:dev.to
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template