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

PHP Version of console.log() for Laravel

PHPz
PHPzOriginal
2024-07-18 05:36:201152browse

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

For Laravel

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

Saasscaleup\LCL\LCLServiceProvider::class,

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

'LCL' => Saasscaleup\LCL\Facades\LCLFacade::class,

Configuration

Publish Config, Migration, and View Files

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

Run Migration

Create the stream_console_logs table:

php artisan migrate

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!

Statement:
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
Previous article:Average Waiting TimeNext article:Average Waiting Time