Laravel Log Files Support in PhpStorm

Today I want to look at a new feature in PhpStorm, one that I think many Laravel developers will find very interesting. Now, to be clear, I’m a Developer Advocate at JetBrains, so you might think it’s obvious I’m excited about PhpStorm. Well, I wouldn’t be writing this post if I weren’t genuinely thrilled about it myself. First and foremost, I’m a PHP and Laravel developer, and I write code daily. So yes, I can say from experience: I’m really excited about this one!

So, let’s take a look at how the latest version of PhpStorm has improved logger support!

Improved log files

Until recently, log files in PhpStorm have been pretty… boring. They are huge blobs of text – that’s it:

Now, I don’t know about you, but scrolling through those huge blobs becomes annoying pretty quickly – especially when you’re trying to debug production issues, which is probably the most common use case for reading a log file.

To streamline the experience of working with logs, the latest version of PhpStorm presents log files in a format that’s much easier to understand at a glance. They will now look something like this:

You can see how the lines are color-coded, errors are highlighted in the scroll bar, and links are styled and clickable. On top of that, bigger log files no longer affect PhpStorm’s performance. A special new renderer for log files allows the IDE to highlight only the code that is visible at any given time, which drastically reduces the amount of memory and CPU needed. Naturally, when you scroll, any new lines that appear will be styled properly as well.

Speaking of scrolling, another use case for log files is to tail them in a terminal window. We’ve added the same styling on that output as well, which means that you can keep your log file open and any new lines will be automatically styled correctly:

Log files on remote servers

Another common use case is browsing production log files via SSH. Let’s take a look at how that works in PhpStorm. 

First you need to configure an SSH connection, which you can do by going to Settings | Tools | SSH Configurations.

Next, with the SSH configuration in place, you can start a new SSH session. Go to Tools | Deployment | Browse Remote Host and choose your newly created SSH configuration. 

PhpStorm will open a new tool window for browsing the remote server. You can navigate to the log file, open it, and… 

It looks just the same!

Pretty neat, right?

Finally, let’s talk about settings. You can go to Settings | Editor | Log Highlighting to configure how log files should be styled. You can enable or disable the heatmap (the colored scroll bar), choose whether links are highlighted, patterns, filters, and configure log formats (we’ve got support for Laravel, Symfony, WordPress, and more).

The section that’s probably most interesting is the patterns table, where you can change the styling of highlighted log entries. For example, I don’t like errors being bold, so I can change the error pattern accordingly:

On top of that, you can create your own patterns if you want to, which is pretty powerful if you want to create your own log highlighting rules, or if you’re reading a log file whose format isn’t supported out of the box.

In closing

The new support for log files is quite impressive if you ask me. Introduced in PhpStorm 2024.2, you can experience it now by starting a 30-day free trial or simply updating your IDE if you’re already a PhpStorm user.

PhpStorm : The Lightning-Smart IDE for PHP Programming | The JetBrains Blog

Read More

Latest News

PHP-Releases

PHP 8.4.1 released!

PHP 8.1.31 released!

PHP 8.3.14 released!

PHP 8.2.26 released!

Generated by Feedzy