yamadashy/phpstan-friendly-formatter
PHPStan Friendly Formatter enhances PHPStan output with code frames around errors, a summary of error identifiers and counts, and clean, readable reports. Install via Composer, include the extension in phpstan.neon, and set errorFormat to friendly.
Enhance your PHPStan experience with a formatter that brings your code to life! 🚀
Ever felt lost in a sea of file paths and line numbers? We've been there! That's why we created this formatter to:
composer require --dev yamadashy/phpstan-friendly-formatter
phpstan.neon or phpstan.neon.dist:includes:
- ./vendor/yamadashy/phpstan-friendly-formatter/extension.neon
errorFormat parameter:parameters:
errorFormat: friendly
If you want to make it simpler, setting scripts in composer.json as follows:
{
"scripts": {
"analyze": "phpstan analyze --error-format friendly"
}
}
You can run a short command like this:
composer analyze
You can customize in your phpstan.neon:
parameters:
friendly:
lineBefore: 3 # Number of lines to display before error line (default: 2)
lineAfter: 3 # Number of lines to display after error line (default: 2)
editorUrl: 'phpstorm://open?file=%%file%%&line=%%line%%' # Editor URL (default: null)
The editorUrl option allows you to create clickable links in terminal output that open files directly in your editor.
Available placeholders:
%%file%% - Absolute file path%%relFile%% - Relative file path (useful for Docker/container environments)%%line%% - Line numberEditor examples:
parameters:
friendly:
# PhpStorm / IntelliJ IDEA
editorUrl: 'phpstorm://open?file=%%file%%&line=%%line%%'
# VSCode (with absolute path)
editorUrl: 'vscode://file/%%file%%:%%line%%'
# VSCode (with relative path - for Docker environments, requires base path)
editorUrl: 'vscode://file//your/local/project/path/%%relFile%%:%%line%%'
# Sublime Text
editorUrl: 'subl://open?url=file://%%file%%&line=%%line%%'
Note: When running PHPStan in Docker or other virtualized environments, use
%%relFile%%instead of%%file%%to get the relative path. For VSCode, you may need to prepend your local project path since VSCode requires absolute paths.
When you actually introduce it in GitHub Actions, it will be displayed as follows.
https://github.com/yamadashy/laravel-blade-minify-directive/actions/runs/4714024802/jobs/8360104870
composer test # Run tests
composer cs-fix # Fix code style
composer playground # Test formatter output with sample errors
Distributed under the MIT license.
How can I help you explore Laravel packages today?