Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Phpstan Oneline Laravel Package

grifart/phpstan-oneline

A PHPStan extension that formats each reported error on a single line, making analysis output easier to read, search, and parse in CI logs or terminals. Useful for grep-friendly error reports and cleaner build output.

Deep Wiki
Context7

Getting Started

Install as a dev dependency (never in production):

composer require --dev grifart/phpstan-oneline

Then point PHPStan at the formatter. The package ships a single formatter class, Grifart\PHPStan\OnelineErrorFormatter, which PHPStan accepts anywhere an errorFormat is valid:

# phpstan.neon
parameters:
    errorFormat: Grifart\PHPStan\OnelineErrorFormatter

or ad-hoc from the CLI:

vendor/bin/phpstan analyse --error-format=Grifart\PHPStan\OnelineErrorFormatter

First use case: run it on any project with a handful of known errors and compare against the default table output. You get one line per error of the shape path/to/File.php:42:message, which terminal emulators and most IDEs recognize as a clickable file:line reference. That is the whole point of the package — compact, greppable, jumpable output.

Look at: composer.json to confirm the PHPStan constraint, and your phpstan.neon to see where to drop the errorFormat line. There is nothing else to configure.

Implementation Patterns

Persistent config (recommended). Put errorFormat in the parameters block of the phpstan.neon you actually ship (or a shared phpstan-baseline.neon-adjacent file), so every developer and CI run gets the same output without remembering a flag.

CI logs. This is where the formatter earns its keep. Table output wraps badly in CI log viewers; oneline output is one record per error, trivially greppable and countable:

vendor/bin/phpstan analyse --no-progress --error-format=Grifart\PHPStan\OnelineErrorFormatter > phpstan.log
grep -c '\.php:' phpstan.log   # quick error count

Editor problem matchers. GitHub Actions, GitLab, and VS Code's task system can map ^(.*\.php):(\d+):(.*)$ to clickable diagnostics. Wire a matcher or annotation step that consumes the oneline output rather than the table.

Pre-commit / pre-push hooks. Short output makes failures readable in a terminal that just ran a hook:

vendor/bin/phpstan analyse --no-progress --error-format=Grifart\PHPStan\OnelineErrorFormatter || exit 1

Diff-scoped analysis. Combine with PHPStan's path arguments or a changed-files list to get a tight, clickable error list for a PR — the one-line-per-error shape is what makes this comfortable to scan.

Wrapper script. If teams want different formats locally vs. CI, wrap PHPStan in a shell script that sets --error-format per environment; keep phpstan.neon format-agnostic so overrides are explicit.

Gotchas and Tips

  • No source context. The default table formatter shows the offending code snippet; oneline does not. For tricky errors you will sometimes fall back to table or raw, or just open the file and line.
  • Clickability is terminal-dependent. OSC 8 hyperlinks aren't emitted — the formatter relies on the terminal/IDE recognizing the file:line:message pattern. iTerm2, VS Code's terminal, and most JetBrains terminals do; bare less, some CI web log viewers, and plain SSH sessions won't make it clickable. That's a limitation of the environment, not the package.
  • The FQCN is the formatter name. There is no short alias like oneline registered for you. You must use the fully-qualified Grifart\PHPStan\OnelineErrorFormatter, and the class must be autoloadable (it is, via the package's composer autoload) — a typo yields a confusing "formatter not found" style failure.
  • Version-pin PHPStan. The last release is December 2024, so it targets PHPStan 1.x/2.x-era formatter APIs. If you jump to a PHPStan major that changes the ErrorFormatter contract, verify this still loads before relying on it in CI. Lock both together.
  • --error-format overrides config. CLI flags win over phpstan.neon; don't be surprised when a local flag silently replaces the configured formatter.
  • CI problem matchers need the regex, not the package. The package only formats; making GitHub/GitLab render annotations still requires you to write the matcher/annotation step against the oneline shape.
  • Exit codes are unchanged. PHPStan still returns non-zero on errors, so || exit 1 and pipeline gates behave exactly as with the table formatter.
  • Extension point. If you need a tweak (prefix, machine-readable wrapping), extend OnelineErrorFormatter and register your subclass as the errorFormat. Keep the parent's line construction so clickability and downstream matchers keep working.
  • Not a replacement for baselines. ignoreErrors, baseline, and --generate-baseline all behave identically — the formatter only touches presentation, so existing suppressions carry over unchanged.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
elsayed85/laravel-api-exceptions
ouhssini/laravel-demo-mode
daworks/ncloud-outbound-mailer-driver
gp247/cms
ignibyte/aic-gates
nexa-merchant/blog
novasa/laravel-language-center
opencage/geocode
adolfoholzer/parameters
livenetworks/ln-starter
shitoudev/permissionmanager
johannesclimacus/laravel-tui
hocvt/seotools
vitalybaev/sypexgeo
amphibee/themosis-ignition
gito-me/fast-excel
frankyso/laravel-ipaymu
geolize-studio/laravel-chile
boomerangui/chat
cgv/localized-resource